I am implementing a simple user login using PDO. But it is giving me a warning message :
Notice: Undefined index: id in login.php on line 39.
Code:
<?php
if($_POST)
{
$query = $db->prepare('SELECT * FROM users
WHERE email = :email and password = :pass');
$query->execute(array(':email' => $_POST['email'],
':pass' => $_POST['password']));
$count = $query->rowCount();
if($count==1)
{
$result = $query->fetchAll();
$_SESSION['user'] = $result['id'];
header("location:index.php");
exit;
}
else
{
$_SESSION['message']='Invalid login details.';
header("location:login.php");
exit;
}
}
?>
What am I missing here?