17. Write a PHP program to accept username and password from
the user. Validate it against the login table in the database. If there is a
mismatch between username and password, then, display the error message as
―invalid user name and password; else display the message as ―Login successful‖ on the browser.
Html file :
<html>
<head>
<title>login</title>
</head>
<body>
<center>
<form
action="slip_16.php" method="post">
<table>
<tr><td><label>Email
id :</label></td><td><input type=text
name=emailid></td></tr>
<tr><td><label
>Password :</label></td><td><input
type=password name=password></td></tr>
<tr><td><input
type=submit value="login & continue"></td><td></td></tr>
</table>
</form>
</center>
</body>
</html>
Php file :
<?php
$con=mysql_connect("localhost","root","")
or die("I cannot connect");
//echo "connected
successfuly";
$d=mysql_select_db("bca_programs",$con);
$q=mysql_query("select
* from login");
$emailid=$_REQUEST['emailid']; //echo $emailid;
$password=$_REQUEST['password'];
$n=0;
while($row=mysql_fetch_array($q))
{
if($row[0]==$emailid &&
$row[1]==$password)
$n=1;
}
if($n==1)
echo
"<center><h3>WELCOME USER</h3><center>";
else
echo "<i>Emailid or
Password Missmatch</i>";
?>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.