Save as Login.html Source code in DHtml programming for user authentication
<html>
<head>
<title>Password Protection</title>
<script language="JavaScript" src="authUser.js">
</script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#333366" vlink="#333366" alink="#333366">
<center> <b>Please enter your Username and Password.</b> <p>
<form name="Login"> <table border="1" cellpadding="2" cellspacing="2" bgcolor="#000000">
<tr><td><font color="#ffffff"><b>Username:</b></font>
<input name="Username" type="text">
</td>
</tr>
<tr><td><font color="#ffffff"><b>Password:</b></font>
<input name="Password" type="password">
</td></tr>
</table>
<br>
<input type="button" value="Enter" onClick="authUser(this.form)">
<input type="reset" value="Reset">
</form>
</center>
</body>
</html>
Save as authUser.js Source code in java script
function authUser(form)
{
if (form.Username.value.length == 0 form.Password.value.length == 0)
{
if (form.Username.value.length == 0)
alert("enter the username")
else
alert("enter the password")
location="Login.html"
}
else if ( form.Username.value.length > 8 form.Password.value.length > 8 )
{
alert("Enter a 8 character only")
location="Login.html"
}
else
{
if ((form.Username.value=="student") && (form.Password.value=="student"))
{
location="Welcome.html"
}
else
{
location="UnAuthorized.html"
}
}
}
Save as UnAuthorized.html Source code in Html programming user authentication
<html>
<head>
<title>You are not authorized to enter!</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#333366" vlink="#333366" alink="#333366">
<center>
<h2><b>Sorry!</b></h2>
<p> You have entered invalid login information!
<br> Please return to the form and try again.
</center>
</body>
</html>
Save as Welcome.html Source code in Html programming
<html>
<head>
<title>Username and Password Accepted!</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#333366" vlink="#333366" alink="#333366">
<center> <h2><b>Thank you!</b></h2>
<p> You have entered the correct Username and Password! </center>
</body>
</html>
0 Comments