Guest User

Untitled

a guest
Dec 1st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. // Try and get the salt from the database using the username
  2. $query = "SELECT * FROM `bombay_customers` WHERE `user-name`='$username' LIMIT 1";
  3. $result = mysql_query($query);
  4. if (mysql_num_rows($result) > 0)
  5. {
  6. // Get the user
  7. $user = mysql_fetch_array($result);
  8. // matches the one in the database
  9. $encrypted_pass = md5($password);
  10.  
  11. // Try and get the user using the username & encrypted pass
  12. $query = "SELECT `id`, `user-name` FROM `bombay_customers` WHERE `user-name`='$username' AND `password`='$encrypted_pass'";
  13. $result = mysql_query($query);
  14. if (mysql_num_rows($result) > 0)
  15. {
  16. $user = mysql_fetch_array($result);
  17.  
  18. // Now encrypt the data to be stored in the session
  19. $encrypted_id = md5($user['id']);
  20. $encrypted_name = md5($user['user-name']);
  21. // Store the data in the session
  22. $_SESSION['userid'] = $user['id'];
  23. $_SESSION['username'] = $user['user-name'];
  24. $_SESSION['encrypted_id'] = $encrypted_id;
  25. $_SESSION['encrypted_name'] = $encrypted_name;
  26.  
  27. // Return ok code
  28. $loggedin=TRUE
  29. }
  30. else
  31. {
  32. $loggedin=false;
  33. }
  34. }
  35. else
  36. {
  37. $loggedin=false;
  38. }
Add Comment
Please, Sign In to add comment