I am working on program like guessbook, so if someone want to login have to enter name and password, if true then user will be greet with welcome message else error pass message. This php program will access user.pas that contain :
#kairos,12345
#me,00000
#oke,11111
The problem is program keep showing error pass although username and password are true. I think there is no logic mistakes, but why is the output wrong ????
<? // test.php
if ($kirim)
{
$p=0;
$x = file("user.pas");
for($a=0;$a<count($x) ;$a++)
{
$n = explode(',',$x[$a]);
$d = substr($n[0],1);
if ($d==$nama && $n[1] == $pass )
$p=1;
//print "$d = $nama , $n[1] = $pass <br>";
}
if ($p==1)
print "Welcome ". $nama;
else
print " error pass";
}
?>
<body>
<form method = post action = test.php >
<table align = center>
<tr>
<input type=hidden name=nama value=NULL >
<td>Nama </td><td> <input type=text name=nama > </td> <br></tr>
<input type=hidden name=pass value=NULL >
<tr><td> Password </td> <td><input type=password name=pass ></td> </tr> <br>
<input type =hidden value=NULL name=kirim>
<tr><td><input type = submit value=kirim name=kirim align = center ></td></tr>
</form>
</body>