hey all
i am trying to validate a user's login/password entry with a data file but i cannot get it to work. Can someone please tell me why the below code doesnt do what i want it to do.
(it seems to work only on the $login value and not the $password ie if the $login is the same it will print "Welcome" regardless if the password is correct, however if the $login is wrong it prints "Login/password does not exist" regardless of the password value)
NB the data file is stored in the following format
login;password
thanks daniel
<?
//read in the entire file. Each record becomes an element in the array
$webpass = file("./webpass.txt");
// count the number of records in the array
$number_of_records = count($webpass);
echo"<br>";
echo "<table border=1>\n";
echo "<tr><th bgcolor = \"#CCCCFF\">Login</td>
<th bgcolor = \"#CCCCFF\">Password</td>
<tr>";
for ($i=0; $i<$number_of_records; $i++){
//split up each line
$line = explode( ";", $webpass[$i] );
//compare the exploded data with data from the submitted form
if(($login==$line[0])&&($password=$line[1])){
echo "<tr><td align=center>$line[0]</td>
<td align=center>$line[1]</td>
</tr>";
echo"<br>";
echo"Welcome";
exit;
}
}
echo"Login/password does not exist";
echo "</table>";
?>