Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $password = $_POST['password'];
  4.  
  5. if ($username&&$password)
  6. {
  7.  
  8. include ('config.php');
  9.  
  10. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  11.  
  12. $username = strtolower($username);
  13.  
  14. if (mysql_num_rows($query)!=0)
  15. {
  16.  
  17.  while ($row = mysql_fetch_assoc($query))
  18.  {
  19.     $dbusername = $row['username'];
  20.     $dbpassword = $row['password'];
  21.     $firstname = $row['firstname'];
  22.     $lastname = $row['lastname'];
  23.     $admin = $row['admin'];
  24.  }
  25.  
  26.  // check to see if they match
  27.  if ($username==$dbusername&&md5($password)==$dbpassword)
  28.  {
  29.     $_SESSION['username']=$username;
  30.     $_SESSION['firstname']=$firstname;
  31.     $_SESSION['lastname']=$lastname;
  32.     $_SESSION['admin']=$admin;
  33.     $date = date("Y:m:d:H:i:s");
  34.     $result = mysql_query("UPDATE users SET lastsignin='$date' WHERE username='$username' LIMIT 1") or print ("Can't update entry.<br />" . mysql_error());
  35.     ?>
  36.    
  37. <!-- redirect to homepage after logging in -->
  38. <script type="text/javascript">
  39. <!--
  40. window.location = "index.php"
  41. //-->
  42. </script>
  43.  
  44. <?php
  45.  }
  46.  else
  47.     echo "<error>Incorrect password!</error>";
  48.  
  49. }
  50. else
  51.     die("<error>That user doesn't exist " . mysql_error() . "</error>");
  52.  
  53. }
  54. else
  55.     die("<error>Please enter a user name and password</error>");
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement