Guest User

Untitled

a guest
Feb 20th, 2018
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public function getUserByEmailAndPassword($email, $password) {
  2.  
  3. $sql = "SELECT * FROM users WHERE email = ?"; // SQL Statement
  4. $stmt = $this->conn->prepare($sql); // Prepare the SQL Statement
  5. $stmt->bind_param('s', $email); // Bind the placeholder with the correct data type from the SQL Statement
  6. $stmt->execute(); // Execute the prepared statement
  7. $stmt->store_result(); // Store the prepared statement for later checking
  8.  
  9. // Check to make sure if any data is returned
  10. if($stmt->num_rows) {
  11.  
  12. // Create and append variables
  13. $user = $stmt->bind_result($email);
  14.  
  15.  
  16. // Create a while loop
  17. while($stmt->fetch()) {
  18. // verifying user password
  19. $salt = $user['salt'];
  20. $encrypted_password = $user['encrypted_password'];
  21. $hash = $this->checkhashSSHA($salt, $password);
  22. // check for password equality
  23. if ($encrypted_password == $hash) {
  24. // user authentication details are correct
  25. $stmt->close();
  26. return $user;
  27. }else {
  28.  
  29. }
  30. }
  31. return NULL;
  32. }
  33. }
Add Comment
Please, Sign In to add comment