Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1.     public function loginUser($email, $password) {
  2.  
  3.         $loginQuery = $this->db->prepare("SELECT * FROM users WHERE user_email = :email limit 1");
  4.         $loginQuery->bindParam(':email', $email, PDO::PARAM_STR);
  5.         $loginQuery->execute();
  6.         $user = $loginQuery->fetch();
  7.  
  8.         $db_password = $user['user_password'];
  9.         //var_dump($password, $db_password);
  10.         if (password_verify($password, $db_password)) {
  11.             $_SESSION["userId"] = $user['user_id'];
  12.         }
  13.         if ($user["user_role"] == "admin") {
  14.             header("Location: admin/index.php");
  15.         } else {
  16.             header("Location: profile.php");
  17.         }
  18.         return $user;
  19.  
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement