Guest User

Untitled

a guest
Jan 8th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. //ckeck connection
  2.  
  3. if (mysqli_connect_errno()){
  4. echo "1 connection failed"; // error code number 1 = connection failed
  5. exit();
  6. }
  7.  
  8. $username = $_POST["name"];
  9. $password = $_POST["password"];
  10.  
  11. $namecheckquery = "SELECT username, score, hash, salt FROM users WHERE username = '$username'";
  12.  
  13. $namecheck = mysqli_query($con, $namecheckquery) or die("2: name check query failed"); // error code #2 = name check query failed
  14.  
  15. var_dump($namecheck);
  16. if(mysqli_num_rows($namecheck) !=1)
  17. {
  18. echo "5: Either no user with name, more than one."; //error code number 5 number names does not match one
  19.  
  20. exit();
  21.  
  22. }
  23.  
  24. // get login info from query
  25. $existinginfo=mysqli_fetch_assoc($namecheck);
  26.  
  27. //$salt = $existinginfo["salt"];
  28. //$hash = $existinginfo["hash"];
  29.  
  30. $salt = trim($existinginfo["salt"]);
  31. $hash = trim($existinginfo["hash"]);
  32.  
  33. $loginhash = crypt($password, $salt);
  34. if ($hash != $loginhash)
  35. {
  36. echo "6: Incorrect password"; // error code number 6 password does not hash to match table
  37. exit();
  38. }
  39.  
  40. echo "0/t" .$existinginfo["score"];
Add Comment
Please, Sign In to add comment