Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getUserByEmailAndPassword($email, $password) {
- $sql = "SELECT * FROM users WHERE email = ?"; // SQL Statement
- $stmt = $this->conn->prepare($sql); // Prepare the SQL Statement
- $stmt->bind_param('s', $email); // Bind the placeholder with the correct data type from the SQL Statement
- $stmt->execute(); // Execute the prepared statement
- $stmt->store_result(); // Store the prepared statement for later checking
- // Check to make sure if any data is returned
- if($stmt->num_rows) {
- // Create and append variables
- $user = $stmt->bind_result($email);
- // Create a while loop
- while($stmt->fetch()) {
- // verifying user password
- $salt = $user['salt'];
- $encrypted_password = $user['encrypted_password'];
- $hash = $this->checkhashSSHA($salt, $password);
- // check for password equality
- if ($encrypted_password == $hash) {
- // user authentication details are correct
- $stmt->close();
- return $user;
- }else {
- }
- }
- return NULL;
- }
- }
Add Comment
Please, Sign In to add comment