Hi,
I'm just learning about how to use php and am trying to solve a problem with this part of my login script for checking a text file of members to see if the user name and password they entered into a login page exists and matches one of the records in a flat text file database.
Here's the part of the script that I'm stuck on:
$handler = fopen($filename,'r');
$members = file($filename);
// get username and password
$users_array = explode ("\n",$members);
foreach ($users_array as $users) {
if ($users != "" || $users != NULL) {
// break username and password string into seperate variables.
list($firstname,$lastname,$city,$state,$country,$username,$password) = explode("\t",$users);
if ($_POST["phpAuth_usr"] == trim($username) && md5($_POST["phpAuth_pwd"]) == trim($password)) {
$logged_in = 1;
break;
} else {
$logged_in = 0;
}
} else {
break;
}
} // end foreach
I tried to adapt this script from an existing script that originally only collected two pieces of info when members registered... username and password. I added the Firstname, Lastname, City, State, and Country items myself to the script that adds the user and it correctly adds the info the the flat file (see below). But now it doesn't work when the user tries to login. I suspect that it isn't able to parse through the flat file with the above code as currently written, even though it was able to do so when the only data in the flat file was the username and encrypted password. Here's a sample of a user record from the flat file database:
Jane Smith Anytown CA USA jane 8822d2a2efe231fa6fce5b711df3dc7c
I have a feeling the problem lies between where I've used the list() and explode() functions AND where the script compares the username and password. Maybe it's something to do with the way list() handles the parameters. I don't know!
Any help in solving this is much appreciated.
Best,
Railer :queasy: