0

trying to put an incorrect username and password to see my error message i had this error instead of "Identifiant ou mot de passe incorrecte" can you help me guys ? line 13

<?php
require_once 'inc/functions.php';
reconnect_from_cookie();
if(isset($_SESSION['auth'])){
    header('Location: index.php');
    exit();
}
if(!empty($_POST) && !empty($_POST['username']) && !empty($_POST['password'])){
    require_once 'inc/db.php';
    $req = $pdo->prepare('SELECT * FROM users WHERE (username = :username OR email = :username)');
    $req->execute(['username' => $_POST['username']]);
    $user = $req->fetch();
    if(password_verify($_POST['password'], $user->password)){
        $_SESSION['auth'] = $user;
$_SESSION['flash']['success'] = 'Vous êtes maintenant connecté';
if($_POST['remember']){
    $remember_token = str_random(250);
    $pdo->prepare('UPDATE users SET remember_token = ? WHERE id = ?')->execute([$remember_token, $user->id]);
    setcookie('remember', $user->id . '==' . $remember_token . sha1($user->id . 'ratonlaveurs'), time() + 60 * 60 * 24 * 7);
}
        header('Location: index.php');
        exit();
    }else{
        $_SESSION['flash']['danger'] = 'Identifiant ou mot de passe incorrecte';
    }
}
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
baha
  • 1
  • 1
    If line 13 is the password_verify line, then `$user` is not an object. It could be an array, it could be null/false. Try `var_dump($user)` to find out what it is and what it contains. – aynber Apr 20 '17 at 13:20
  • 2
    Possible duplicate of [Notice: Trying to get property of non-object error](http://stackoverflow.com/questions/22636826/notice-trying-to-get-property-of-non-object-error) – LF00 Apr 20 '17 at 13:26
  • thank you for your response aynber var_dump($user) show me that errorbool(false) Notice: Trying to get property of non-object on line 13 – baha Apr 20 '17 at 14:02

0 Answers0