In this Tutorial, we are going to learn how we can Write a PHP program to make a login page.
Note :--
we all know that we can write <html> tags in PHP so I have used that method.
I have used <table> tags for style.
Program :--
<html>
<head>
<title>
login-page
</title>
<center>
<table border=1 bgcolor=cyan height=250 width=450 cellpadding=0 cellspacing=0>
<form method=post action="">
<tr><th>Enter User-Name :</th><td><input type=text name=uname></td></tr><br>
<tr><th>Enter PassWord :</th><td><input type=password name=pass></td></tr><br>
<tr><center><th colspan=2><input type=submit value=validate></th></center></tr><br>
</form>
</table>
</center>
</head>
</html>
<?php
$name=$_POST['uname'];
$pass=$_POST['pass'];
if(isset($_POST['uname']))
{
if($name=="" || $pass=="")
{
echo "<script>alert('All fields required')</script>";
}
else
{
if($name==$pass)
{
echo "<script>alert('Login Success full')</script>";
}
else
{
echo "<script>alert('Login Error')</script>";
}
}
}
?>
Comments
Post a Comment