if(isset($_POST["submit"]))
{
$email = trim($_POST['email']);
$upass = trim($_POST['password']);
if($user_login->login($email,$upass))
{
$user_login->redirect("index.php");
}
}
public function login($email,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT * FROM table WHERE userEmail=:email_id");
$stmt->execute(array(":email_id"=>$email));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if($userRow['userStatus']=="Y")
{
if($userRow['userPass']==md5($upass))
{
$_SESSION['userSession'] = $userRow['userID'];
return true;
}
else
{
header("Location: login.php?error");
exit;
}
}
else
{
header("Location: login.php?inactive");
exit;
}
}
else
{
header("Location: login.php?error");
exit;
}
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
I've granted all the privileges to the database. The user is able to signup but when loggedin it doesn't log in but also doesn't show any error and directs the user to index.php without creating session.