对 PHP 并不陌生,但对 PDO 来说只有一天的历史。我肯定在这里做错了什么。
$query = $conn->prepare("SELECT * FROM admins WHERE username = :username AND password = :password");
$query->execute(array('username' => $username,'password' => sha1($password)));
$result = $query->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0)
{
$_SESSION['user']['who'] = $result[0]['who'];
$_SESSION['user']['email'] = $result[0]['email'];
$_SESSION['user']['username'] = $result[0]['username'];
echo REFRESH;
}
else
{
$message = "Invalid username / password.";
}
我可以正确声明它们的唯一方法$_SESSIONS
是如果我使用我$result[0]['fieldName'];
如何才能通过它访问它$result['fieldName'];
?