0
<?php 
if(isset($_POST['login']))
{
    require 'connection.php';
    include 'password.php';

    $email = $_POST['email'];
    $password = $_POST['pass'];

    $query = $dbh->prepare("SELECT id,name,email,password FROM users WHERE email = :email");
    $query->bindParam(':email', $email, PDO::PARAM_STR);
    $query->execute();

    $userData = $query->fetch(PDO::FETCH_ASSOC);
    $userEmail = $userData['email'];
    $hash = $userData['password'];

    if(password_verify($password, $hash) && $email == $userEmail)
    {
        session_start();
        $_SESSION['sess_user_id'] = $userData['id'];
        $_SESSION['sess_name'] = $userData['name'];
        echo "<script type='text/javascript>window.location = 'home.php'; </script>";
    }
    else
    { 
        echo "<script>alert('Incorrect email/password');</script>";
    }
}
?>

the include 'password.php' is the library for php 5.5 password function to be able to be used in php 5.3 and 5.4.

so this is my script for login but i keep getting incorrect email/password but i filled it in correctly. what am i doing wrong?

TIA!

Edited by nadiam

3
Contributors
3
Replies
28
Views
3 Years
Discussion Span
Last Post by thirsty.soul
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.