I try to make a very very simple user authentication but fail. here is the program :
//input.php
<?
if($submit){
$auth=0;
$filename='user2.txt';
$fp=fopen($filename,'r');
$file_contents=fread($fp,filesize($filename));
$lines=explode("\n",$file_contents);
$pass=md5("$name:$password");
foreach($lines as $line){
list($username,$passcode)=explode(':',$line);
if( $username==$name && $passcode==$pass){
echo "Hello $name ";
$auth=1;
break;
}
}
if($auth !=1){
echo "you are not user";
}
}// end if submit
echo'
<html>
<head>
<title>test</title>
</head>
<body>
<form action="input2.php" method="post">
Nama : <input type="text" name="name"><br><br>
Pass : <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="proses">
</form>
</body>
</html>
';
?>
and here is the user2.dat :
super user:0a5acaa3c10612386c96e8562a381d3e
user1:e9b9b055ddc04ffbe90be3f266ef6fd3
user2:a59255ecf1edf164583a3c58aa19c19f
when i remove the code '$passcode==$pass' it can work.
Please help me .