Ok, basically, I'm making a BBS with user/password authentication. The users.dat file is in the format of 'usernameassword' then basically i use the $string = file('users.dat'); function to put the file into an array. then i combine the input fields from the user to form the syntax described above, so if they put USER = johndoe & PASSWORD = 'password', it would translate it to 'johndoeassword'. Then I have it search the array for 'johndoeassword', however, unless that is that last element (last line in the file), it returns invalid username/password. I will include the code below so you can take a look at it. Thank you very much for your consideration and time.
CONTENTS OF USERS.DAT:
------------------
------------------
testing:testing
why:why
mattassword
nate:nate
retry:retry
so, the users are:
testing, why, matt, nate, retry
and the passwords are respectively:
testing, why, password, nate, retry
CONTENTS OF LOGIN.PHP (MAIN SCRIPT FOR CHECKING):
<?
include('c:/web/cgi-bin/forum/config/config.cfg');
$users = file('c:/web/cgi-bin/forum/data/users.dat');
$stringage = $USRNM; $stringage .= ':'; $stringage .= $PWD;
if(array_search ($stringage, $users)) {
echo 'Validation Successful';
}
else {
$errorlevel = '8';
echo "<BODY onLoad=window.setTimeout(\"location.href='../bbs.php'\",0) text=\"#000000\">"; //if user or password invalid, return to bbs main
}
$temp = $datapath; //ignor these, they have to do with
$temp .= $httpdat; //http referer validation in a later
$httplst = file($temp); //script
$httpnum = count($httplst); // same here
?>
it will only return "Validation Successful" when i use the 'retry' user, however, if i use a wrong password it doesn't work. So I know it actual does search the array, but it doesn't seem to search the first 6 lines.
CONTENTS OF USERS.DAT:
------------------
------------------
testing:testing
why:why
mattassword
nate:nate
retry:retry
so, the users are:
testing, why, matt, nate, retry
and the passwords are respectively:
testing, why, password, nate, retry
CONTENTS OF LOGIN.PHP (MAIN SCRIPT FOR CHECKING):
<?
include('c:/web/cgi-bin/forum/config/config.cfg');
$users = file('c:/web/cgi-bin/forum/data/users.dat');
$stringage = $USRNM; $stringage .= ':'; $stringage .= $PWD;
if(array_search ($stringage, $users)) {
echo 'Validation Successful';
}
else {
$errorlevel = '8';
echo "<BODY onLoad=window.setTimeout(\"location.href='../bbs.php'\",0) text=\"#000000\">"; //if user or password invalid, return to bbs main
}
$temp = $datapath; //ignor these, they have to do with
$temp .= $httpdat; //http referer validation in a later
$httplst = file($temp); //script
$httpnum = count($httplst); // same here
?>
it will only return "Validation Successful" when i use the 'retry' user, however, if i use a wrong password it doesn't work. So I know it actual does search the array, but it doesn't seem to search the first 6 lines.