Advertisement
Guest User

Untitled

a guest
May 1st, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2. if($_POST['login']):
  3.  
  4. $username = stripslashes(mysql_real_escape_string($_POST['username']));
  5. $password = stripslashes(mysql_real_escape_string($_POST['password']));
  6.  
  7. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  8. $numrows = mysql_num_rows($query);
  9. $row = mysql_fetch_array($query);
  10. $dbusername = $row['username'];
  11. $dbpassword = $row['password'];
  12. $dbstaffid = $row['staffid'];
  13. $dblevel = $row['level'];
  14. $date = date('d-M-Y : h:i:s a');
  15.  
  16. if($username&&$password)
  17. {
  18.   if($numrows!=0)
  19.   {
  20.    if($username==$dbusername&&md5($password)==$dbpassword)
  21.    {
  22.     $sql = mysql_query("select * from biodata where staffid='$dbstaffid'") or die(mysql_error());
  23.     $row = mysql_fetch_array($sql);
  24.     $sqlUpdate = mysql_query("UPDATE users SET last_log='$date' WHERE staffid='$dbstaffid'");
  25.    
  26.     $_SESSION['name']  = $row['name'];
  27.     $_SESSION['auths'] = true ;
  28.     $_SESSION['username'] = $dbusername;
  29.     $_SESSION['level'] = $dblevel;
  30.     $_SESSION['staffid'] = $dbstaffid;
  31.     header("location:?page=user_info");
  32.    }
  33.    else
  34.      $msg = "Incorrect password !";
  35.   }
  36.   else
  37.     $msg = "User not exist !";
  38. }
  39. else
  40.  $msg = "Fill the blanks !";
  41.  
  42. endif;
  43.  
  44. include("templates/login.html");
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement