问问题
571 次
2 回答
1
$USERS[$_POST["username"]]
when you leave the username
input parameter blank, then it'll evaluate to:
$USERS[""]
what is a key that doesn't exist:
check for:
if(isset($_POST['ac'], $_POST["username"], $USERS[$_POST["username"]], $_POST["password"])) { /* ... */ }
instead of only checking for if sent:
if(isset($_POST['ac'])) { /* ... */ }
于 2013-04-30T15:18:22.790 回答
0
This error comes from the fact that you're using the user input $_POST['username']
as a key into the array $USERS
without checking first that the key exists.
You could use isset
to check that the key exists before accessing it, like this:
if (isset ($USERS[$_POST['username']]) && $USERS[$_POST['username']] == $_POST['password'])...
于 2013-04-30T15:18:10.223 回答