Write a PHP program to accept user ID and password and check whether it is valid or not|EasyCoding45
Write a PHP program to accept user ID and password and check whether it is valid or not
In this Tutorial, we are going to learn how we can Write a PHP program to accept user ID and password and check whether it is valid or not.
Important Notes :--
We all Know that we can write html tags in PHP so i have used in it. Don't get confuse in it.
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 Successfull')</script>";
}
else
{
echo "<script>alert('Login Error')</script>";
}
}
}
?>
Output :--
Comments
Post a Comment