0
我正在使用PDO实现简单的用户登录。但它给我一个警告消息:使用PDO登录 - Php
注意:未定义指数:ID中的login.php在线39
代码:
<?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;
}
}
?>
缺少什么我在这里?
[PHP: “注意:未定义变量” 和 “通知:未定义的索引”]的可能重复(http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice -dedefined-index) – Gajus
fetchAll意味着多个行 – Luceos
使用''var_dump($ result)''来查看PDO返回的结果。 –