What's wrong with my code?
Whenever I try entering the username and password, everything is Access Denied! Pls help me. This is due on Monday. 😕
Users.txt
kim lalas
denise ben
jeselle neil
Log in Page
<form action="quiz2_2.php" method=post>
Input name:
<input type=text name=name><br>
Input password:
<input type=password name=pword>
<input type=submit value=SUBMIT>
</form>
PHP File
<?php
$fh=fopen("users.txt","r");
$flag=false;
while(!feof($fh))
{
$user=fgets($fh);
$u=explode(" ",$user);
if(($u[0]==$_POST["name"])&&($u[1]==$_POST["pword"]))
{
$flag=true;
break;
}
}
fclose($fh);
if($flag==true)
echo "Access Granted";
else
echo "Access Denied";
?>