This is the exact code I am using:
<?
function CheckUser($myusername)
{
if ($myFile = fopen("users","r"));
$ValidLogin = 0;
while (!feof($myFile))
{
$myLine = fgets($myFile,255);
trim($myusername);
trim($myLine);
print ("From Data File: $myLine<br>\n");
print ("From Username: $myusername<br>\n");
//if (strcmp($myusername,$myLine)==0)
if ($myusername == $myLine)
{
$ValidLogin = 1;
print ("VALID!! $ValidLogin<br><br>\n");
return $ValidLogin;
}
else
print ("NOT VALID!! $ValidLogin<br><br>\n");
}
fclose($myFile);
}
//if (($myusername=="TheWalrus" || $myusername=="Strawberry") && ($mypassword=="password")) THIS LINE WORKS FINE
if ((CheckUser($myusername))&& ($mypassword=="password"))) //THIS IS MY PROBLEM LINE
{
$LoggedIn=1;
echo "Login is Secure";
}
else
{
$LoggedIn=0;
echo "Login Has Failed for ".$myusername." with ".$mypassword." ";
}
?>
I've pulled $myLine out of a text file and when I vire the output print statements within the While loop the pair that looks identical should be yield a correct response and set ValidLogin=1... right?