Advertisement
Guest User

Untitled

a guest
Jan 16th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function loginUser($username, $password)
  2. {
  3.  
  4. include('assets/con.php');
  5.  
  6. /* Set the salt. */
  7. $salt = 'JwethYGkuuygTYFIYTFrfkuyGUTf75kUY4uyk6';
  8.  
  9. /* Apply SHA512 password and salt encryption. */
  10. $password = hash('SHA512', $password);
  11. $salt = hash('SHA512', $salt);
  12.  
  13. $query = 'SELECT username FROM users WHERE username = ? AND password = ? AND pass_salt = ?';
  14. if( $statement = $con->prepare($query) )
  15. {
  16. $statement -> bind_param( 'sss', $username, $password, $salt );
  17. $statement -> execute();
  18. $statement -> store_result();
  19. $num_row = $statement -> num_rows;
  20. $statement -> bind_result($username);
  21. $statement -> fetch();
  22. $statement -> close();
  23. }
  24.  
  25. else die( "Failed to prepare query." );
  26.  
  27. if( $num_row === 1 )
  28. {
  29. $_SESSION['userName'] = $username;
  30. return true;
  31. }
  32. return false;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement