Invalid (use database to store user name and
password).
Html file :
<html>
<head>
<script
type="text/javascript">
function
validate()
{
uname=document.getElementById('uname').value;
pwd=document.getElementById('pwd').value;
}
</script>
</head>
<body>
<form
action="slip_29-1.php" method=get>
Enter
UserName<input type=text name=uname id=uname><span id=a></span><br>
Enter
Password<input type=password name=pwd id=pwd><br>
<input
type=SUBMIT value=SUBMIT onClick=validate()>
</form>
</body>
</html>
Php file :
<?php
$uname=$_GET['uname'];
$password=$_GET['pwd'];
$con=mysql_connect("localhost","root","")
or die("I cannot connect");
$d=mysql_select_db("bca_programs",$con);
$q=mysql_query("select
* from login");
$n=0;
while($row=mysql_fetch_array($q))
{
if($row[0]==$uname &&
$row[1]==$password)
$n=1;
}
if($n==0)
echo
"invalid username or password";
?>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.