Advertisement
Guest User

Untitled

a guest
May 16th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public function loggingIn(){
  2. if(!empty($this->m_sUsername) && !empty($this->m_sPassword)){
  3. $PDO = Db::getInstance();
  4. $stmt = $PDO->prepare("SELECT * FROM users WHERE username = :username");
  5. $stmt->bindValue(":username", $this->m_sUsername, PDO::PARAM_STR);
  6. $stmt->execute();
  7.  
  8. if($stmt->rowCount() > 0){
  9. $result = $stmt->fetch(PDO::FETCH_ASSOC);
  10. $password = $this->m_sPassword;
  11. $hash = $result['password'];
  12.  
  13. if(password_verify($password, $hash)){
  14. session_start();
  15. $_SESSION["loggedIn"] = $result['usersid'];
  16. $_SESSION["loggedIn"] = $result ['username'];
  17. session_write_close();
  18. return true;
  19. }else{
  20. return false;
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement