-2
class User{
protected $pdo;
function __construct($pdo){
    $this->pdo = $pdo;
}
public function checkInput($var){
    $var = htmlspecialchars($var);
    $var = trim($var);
    $var = stripcslashes($var);
    return $var;
}
  1. and here it show Only variables should be passed by reference

    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();
    
  2. here the redirecting page not reloads just shows the html error

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

    } }

tereško
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

-1

It seems that your bind_params second parameter are reference. In strict standard this should be variables so this code

$stmt ->bindParam(":password", md5($password), PDO::PARAM_STR);

Should be

 $hashed_pass =  md5($password);
 $stmt ->bindParam(":password", $hashed_pass , PDO::PARAM_STR);

The same goes if you use password_hash instead of md5

You may read this question for more information Strict Standards: Only variables should be passed by reference

keysl
  • 2,127
  • 1
  • 12
  • 16