Jump to content


Go to solution Solved by Jacques1,

Recommended Posts

i tired the password_verify() but im not doing it right i think. got a warning:




 password_verify() expects exactly 2 parameters, 1 given


trying to login code:


    $email = $_POST['email'];
    $password = $_POST['pass'];
     require "connection.php";
    $emails = mysqli_real_escape_string($con, $email);
    $query = "SELECT id, name, email, password, salt FROM users WHERE email = '$emails';";
    $result = mysqli_query($con, $query);
    if(mysqli_num_rows($result) == 0) // User not found. So, redirect to login_form again.
        echo "<script>alert(\"User does not exist!\")</script>";
    $userData = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $hash = $userData['password'];
    if(password_verify($password) != $hash)
        echo "<script>alert(\"Incorrect Password!\")</script>";
        $_SESSION['sess_user_id'] = $userData['id'];
        $_SESSION['sess_name'] = $userData['name'];
        header('Location: home.php');

Link to comment
Share on other sites

  • Solution

Please read the manual. Or just use common sense: You verify a password against a given hash, so it's only natural that there are two parameters. The first parameter is for the password, the second is for the hash. If the password matches the hash, the function returns true, otherwise it returns false.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.