If statement acting very wierd, not recognizing simple input
Posted: Thu Mar 16, 2006 8:08 pm
My script has a username/password combo stored in a file, file.pass, with the username on the first line and password on the second, so...
FILE.PASS:
----------------
bob
bobpass
----------------
$userpass = file("file.pass");
therefore
echo $userpass[0]; // this would return 'bob'
echo $userpass[1]; // this returns 'bobpass'
So then why doesn't a form, with two fields, where one = username and one = password not work in the following scenario:
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == $userpass[0]) {
echo "success!";
} else {
echo "error!";
}
And I keep getting "error!" instead of "success!" -- why???
FILE.PASS:
----------------
bob
bobpass
----------------
$userpass = file("file.pass");
therefore
echo $userpass[0]; // this would return 'bob'
echo $userpass[1]; // this returns 'bobpass'
So then why doesn't a form, with two fields, where one = username and one = password not work in the following scenario:
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == $userpass[0]) {
echo "success!";
} else {
echo "error!";
}
And I keep getting "error!" instead of "success!" -- why???