0
public function login($email,$password){
    $stmt=$this->pdo->prepare("SELECT 'user_id' from 'users' WHERE 'email'= :email  AND 'password'=:password");
    $stmt->bindParam(":email",  $email, PDO::PARAM_STR);
    $stmt->bindParam(":password",  md5($password) , PDO::PARAM_STR);
    $stmt->execute();

    $user=$stmt->fetch(PDO::FETCH_OBJ);
    $count=$stmt->rowCount();

    if($count > 0){
        $_SESSION['user_id'] = $user->user_id;
        header('Location: home.php');

    }else{
        return false;
    }

The count variable is always showing 0 on echoing in php even though my database has enteries and so even after entering the correct username and password I am not forwared to home.php page. What might be the problem?

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
  • 1
    **Danger**: You are using [an unsuitable hashing algorithm](http://php.net/manual/en/faq.passwords.php) and need to [take better care](https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet) of your users' passwords. – Quentin Mar 13 '18 at 14:27
  • `'email'= :email` — `'email'` is the **string** email and not the value of the column named email. – Quentin Mar 13 '18 at 14:29

0 Answers0