login system html code example

Example 1: how to make a working login system using code

<!DOCTYPE html>
<html>
<head>
	<title>Login</title>
	<script>
  firebase.initializeApp(firebaseConfig);
  const auth = firebase.auth();
  function signUp(){
    var email = document.getElementById("email");
    var password = document.getElementById("password");
    const promise = auth.createUserWithEmailAndPassword(email.value, password.value);
    promise.catch(e => alert(e.message));
    alert("Signed Up");
  }
  function signIn(){
    var email = document.getElementById("email");
    var password = document.getElementById("password");
    const promise = auth.signInWithEmailAndPassword(email.value, password.value);
    promise.catch(e => alert(e.message));
  }
  function signOut(){
    auth.signOut();
    alert("Signed Out");
  }

auth.onAuthStateChanged(function(user){
    if(user){
      var email = user.email;
      alert("Signed in as " + email);
      //Take user to a different or home page

      //is signed in
    }else{
      alert("No Active User");
      //no user is signed in
    }
  });g
	</script>
<style type="text/css">
	body{
	background-color: #55d6aa;
}
h1{
	background-color: #ff4d4d;
	margin: 10px auto;
	text-align: center;
	color: white;
}
#formContainer{
	background-color: white;
	box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);

	width: 25%;
	height: 45;
	margin: 10px auto;
}
#header{
	width: 100%;
	height: 10px;
	background: black;
}
#email{
	width: 70%;
	height: 40px;
	display:block;
	margin: 25px auto;
	border: none;
	outline: none;
	border-bottom: 2px solid black;
}
#password{
	width: 70%;
	height: 40px;
	display: block;
	margin: 10px auto;
	border: none;
	outline: none;
	border-bottom: 2px solid black;
}
#signUp{
	background-color: #ff4d4d;
	color: white;
	border: none;
	font-weight: bold;
	padding: 15px 32px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 13px;
	margin-top: 20px;
	margin-left: 50px;
}
#signIn{
	background-color: #32ff7e;
	color: white;
	font-weight: bold;
	border: none;
	padding: 15px 35px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	font-size: 13px
}
#signOut{
	background-color: #FFA500;
	color: white;
	border: none;
	padding: 12px 32px;
	border-radius: 10px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 13px;
	margin-top: 9px;
	margin-left: 74px;
	font-weight: bold;
}
button: hover{
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 7px 50px 0 rgba(0,0,0,0,.19);
}
</style>
</head>
<body>
	<h1>Login Here</h1>
	<div id="formContainer">
		<div id="header"> </div>
  <input type="email" placeholder="Email" id="email">
  <input type="password" placeholder="Password" id="password">

 <button onclick="signUp()" id="signUp"> Sign Up </button>
  <button onclick="signIn()" id="signIn"> Sign In </button>
  <button onclick="signOut()" id="signOut"> Sign Out </button>
Continue</a>
</body>
</html>

Example 2: html login page

<html>
<head>
<title>Account</title>
<style>
body
{
	background-color:#ffda08;
}
table
{
	border:1px white;
	margin-top:200px;
	margin-left:500px;
	background-color:white;
	padding:20px
}
#btn
{
	width:200px;
	height:50px;
	background-color:#1ee3d2;
}

</style>
</head>
<body>
	<form name=frmNewAcc>
		<table border=0 cellspacing=5px>
	<tr>
		<th colspan=3><input class=in =text name=txtuname placeholder="Enter your account name"></th>
	</tr>
	<tr>
		<th colspan=3><input class=in type=password name=txtupass placeholder="Enter your new password"></th>
	</tr>
	<tr>
		<th colspan=3><input  class=in type=password name=txtuconfirmpass placeholder="Enter confirmed password"></th>
	</tr>
	<tr>
		<th colspan=3><input id=btn type=button value="Create new account"></th>
		<a href="Login task 1.html">Go back to login</a>
	</tr>

	
</table>
</form>
</body>
</html>

Example 3: login form html

<!DOCTYPE html>   
<html>   
<head>  
<meta name="viewport" content="width=device-width, initial-scale=1">  
<title> Login Page </title>  
<style>   
Body {  
  font-family: Calibri, Helvetica, sans-serif;  
  background-color: pink;  
}  
button {   
       background-color: #4CAF50;   
       width: 100%;  
        color: orange;   
        padding: 15px;   
        margin: 10px 0px;   
        border: none;   
        cursor: pointer;   
         }   
 form {   
        border: 3px solid #f1f1f1;   
    }   
 input[type=text], input[type=password] {   
        width: 100%;   
        margin: 8px 0;  
        padding: 12px 20px;   
        display: inline-block;   
        border: 2px solid green;   
        box-sizing: border-box;   
    }  
 button:hover {   
        opacity: 0.7;   
    }   
  .cancelbtn {   
        width: auto;   
        padding: 10px 18px;  
        margin: 10px 5px;  
    }   
        
     
 .container {   
        padding: 25px;   
        background-color: lightblue;  
    }   
</style>   
</head>    
<body>    
    <center> <h1> Student Login Form </h1> </center>   
    <form>  
        <div class="container">   
            <label>Username : </label>   
            <input type="text" placeholder="Enter Username" name="username" required>  
            <label>Password : </label>   
            <input type="password" placeholder="Enter Password" name="password" required>  
            <button type="submit">Login</button>   
            <input type="checkbox" checked="checked"> Remember me   
            <button type="button" class="cancelbtn"> Cancel</button>   
            Forgot <a href="#"> password? </a>   
        </div>   
    </form>     
</body>     
</html>

Example 4: login screen html

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body ,html{font-family: Arial, Helvetica, sans-serif;;}
form{
    width:fit-content;
    padding: 60px;
   
   
    height:fit-content;
    margin:0 auto;
    margin-top: 2%;
    background-color: #f9f9f9
}
/* Full-width input fields */
.form-control {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

/* Set a style for all buttons */
button{
  background-color: #4CAF50;
  color: white;
  border: none;
  cursor: pointer;
  width: 60%;
  margin: 5px auto;
  padding: 15px;
      box-shadow: 0px 5px 5px #ccc;
      border-radius: 5px;
      border-top: 1px solid #e9e9e9;
  display:block;
  text-align:center;
}
.signup{
    background-color:blue;
    margin-bottom:20px;
}
.login-box {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      padding: 15px;
      background-color: #fff;
      box-shadow: 0px 5px 5px #ccc;
      border-radius: 5px;
      border-top: 1px solid #e9e9e9;
    }
button:hover,#btn-signup:hover {
  opacity: 0.8;
}



/* Center the image and position the close button */
.imgcontainer {
  text-align: center;
  margin: 24px 0 12px 0;
  position: relative;
}

img.avatar {
  width: 40%;
  border-radius: 50%;
}

.container {
  padding: 16px;
}

span.psw {
  float: right;
  padding-top: 16px;
}

h2,p{
    text-align:center;
}



/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
  span.psw {
     display: block;
     float: none;
  }
  
}
</style>
</head>
<body>



  
  <form  action="/action_page.php" method="post">

    <h2>Welcome To Newscongragated</h2>
    <p>Sign in</p>
    <div class="container">
      
      <label for="email"><b>Email</b></label>
          <input
            type="email"
            class="form-control"
            id="email"
            placeholder="Enter your email"
                 required pattern='/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/'>

     

      <label for="name"><b>Password</b</label>
          <input
            type="password"
            class="form-control"
            id="password"
            placeholder="Enter your password"
                 minlength="8"
                 required>
        
      <button type="submit">Login</button>
      <button type="button"
          href="account/signup.php"
          class="signup" >
            Sign Up
        </button>
      <a href="./resetpassword.php">Forgot your password? </a>

      
    </div>

    

    
  </form>


</body>
</html>

Example 5: html login scripts

<form action="action_page.php" method="post">
  <div class="imgcontainer">
    <img src="img_avatar2.png" alt="Avatar" class="avatar">
  </div>

  <div class="container">
    <label for="uname"><b>Username</b></label>
    <input type="text" placeholder="Enter Username" name="uname" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" required>

    <button type="submit">Login</button>
    <label>
      <input type="checkbox" checked="checked" name="remember"> Remember me
    </label>
  </div>

  <div class="container" style="background-color:#f1f1f1">
    <button type="button" class="cancelbtn">Cancel</button>
    <span class="psw">Forgot <a href="#">password?</a></span>
  </div>
</form>

Tags:

Misc Example