Advertisement
Guest User

Untitled

a guest
Jun 13th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. include('LoginLib.php');
  3. session_start(); //must call session_start before using any $_SESSION variables
  4.  
  5. $GLOBALS['username'] = cleanQuery($_POST['username']);
  6. $username = cleanQuery($_POST['username']);
  7. $password = cleanQuery($_POST['password']);
  8.  
  9. $query = "SELECT Password, Salt, ID
  10.         FROM personaldata
  11.         WHERE Username = '$username';";
  12. $result = mysql_query($query);
  13.  
  14. if(mysql_num_rows($result) < 1) //no such user exists
  15. {
  16.     echo "No such user.";
  17.     die();
  18. }
  19.  
  20. $userData = mysql_fetch_array($result, MYSQL_ASSOC);
  21. $hash = sha1( $userData['Salt'] . sha1($password) );
  22.  
  23. if($hash != $userData['Password']) //incorrect password
  24. {
  25.     echo "Incorrect password";
  26.     die();
  27. }
  28. else
  29. {
  30.     $GLOBALS['userid'] = $userData['ID'];
  31.     validateUser(); //sets the session data for this user
  32. }
  33.  
  34. mysql_close($con);
  35.  
  36. echo "Login succesful.";
  37. header('Location: Game.php');
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement