A Simple Password Authentication Form - PHP

The given PHP example helps you to make a simple password authentication form.
if (!empty($loginme)) {
  $connection = mysql_pconnect($dbhost='localhost',$dbuser='root',$dbpass='root');
  $query = "SELECT id FROM customer WHERE email='".mysql_real_escape_string($admin)."' AND password='".mysql_real_escape_string($password)."'";
  $result = mysql_query($query, $connection);
  $num = mysql_num_rows($result);
  if ($num > 0){
     header("Location: home.php"); // do what you want
     echo "username and password are either incorrect or not in the database";
<form method="post" action="">
Username: <input type="text" name="admin"><br>
Password: <input type="password" name="password"><br>
<input type="submit" name="loginme" value="Login Me">

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...