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???
If statement acting very wierd, not recognizing simple input
Moderator: General Moderators
-
ninjapheret
- Forum Newbie
- Posts: 2
- Joined: Thu Mar 16, 2006 8:02 pm
- ambivalent
- Forum Contributor
- Posts: 173
- Joined: Thu Apr 14, 2005 8:58 pm
- Location: Toronto, ON
Code: Select all
$userpass = file("file.pass");
var_dump($userpass);Code: Select all
array(2) { [0]=> string(4) "bob " [1]=> string(7) "bobpass" }- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
-
ninjapheret
- Forum Newbie
- Posts: 2
- Joined: Thu Mar 16, 2006 8:02 pm
Ah trim might just do it! Lemme try that in one second!
The reason I knew they were matching is that I did an else{} statement after the un/pw check that did the following:
echo $userpass[0];
echo $username;
echo $userpass[1];
echo $password;
and they matched up perfectly... but there might have been a rogue space now that i think about it... ill post back in a minute.
The reason I knew they were matching is that I did an else{} statement after the un/pw check that did the following:
echo $userpass[0];
echo $username;
echo $userpass[1];
echo $password;
and they matched up perfectly... but there might have been a rogue space now that i think about it... ill post back in a minute.