0

i've got a problem with password verify. I'm trying to fetch an hash from my password column and then verify with the password from form. I'm not sure why it doesn't work:

        $pass = mysqli_query($link, "SELECT password FROM male_users WHERE email=$email");
        $hash = mysqli_fetch_assoc($pass);
        if (password_verify($password, $hash)) {
            echo('Hello');
        } else  {
            echo('Email or Password not mach');
        }

It turns back an error: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given but i found on stack that people succesfully uses that. What am i doing wrong? Thnx in advance! best regards

5
  • 2
    Learn how to use quotes. Commented May 7, 2016 at 9:42
  • Do you really have separate database tables for users based on their gender? Commented May 7, 2016 at 9:43
  • where email = '$email' Commented May 7, 2016 at 9:46
  • try like this WHERE email='".$email."'); Commented May 7, 2016 at 9:47
  • Also, your code is vulnerable to SQL injection, and mysqli_fetch_assoc() returns an array not a string. Commented May 7, 2016 at 9:48

1 Answer 1

1

try like this and your mysqli_fetch_assoc return array so use $hash['password'] insted of $hash and finally use single quotes in where condition .

 $pass = mysqli_query($link, "SELECT password FROM male_users WHERE email='$email'");
    $hash = mysqli_fetch_assoc($pass);
    if (password_verify($password, $hash['password'])) {
        echo('Hello');
    } else  {
        echo('Email or Password not mach');
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.