Advertisement
Guest User

Untitled

a guest
May 1st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. $formUsername = mysql_real_escape_string($formUsername);
  3. $formPassword = mysql_real_escape_string($formPassword);
  4.  
  5. // Gets user record via. MySQL
  6. $q = $DB->RunQuery("SELECT * FROM `users` WHERE `username` = '$formUsername'");
  7.  
  8. //Verifcation Check
  9. if(mysql_num_rows($q) <= 0 || mysql_num_rows($q) > 1) {
  10. die("Username or password are incorrect!");
  11. }
  12.  
  13. // Fetches the data
  14. $u = mysql_fetch_assoc($q);
  15.  
  16. // Builds form password hash
  17. $salt = $u['salt'];
  18. $formPasswordH = md5(md5($formPassword) . $salt);
  19.  
  20. //Verification Check
  21. if($u['password'] != $formPasswordH) {
  22. die("Username or password are incorrect!");
  23. } else {
  24. //Assign session token and cookie
  25. $isAuthenticated = true;
  26. $sessionToken = sha1( "s4l7" . $u['password'] );
  27. setcookie("QSessionID",intval($u['userid']));
  28. setcookie("QSessionToken",$sessionToken);
  29. echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php?YOURLOGIN=1\" />";
  30. exit();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement