note 28350 added to function.md5

From: Date: Fri, 10 Jan 2003 10:05:00 +0000
Subject: note 28350 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-41945@lists.php.net to get a copy of this message
Hello, I want to write a simple but a good login script. I can't use SQL so I put the user information in a textfile. for example users.inc The password's have to be crypted, by crypt() or md5(). When I run the following script (check.php): $userURL = "users.inc"; $fd = fopen($userURL,"r"); $fd = fread($fd,filesize($userURL)); $users = explode("\n",$fd); for($i = 0; $i < count($users); $i++){ $row = explode("|",$users[$i]); $a = crypt($passwd); if($row[0] == $user && crypt($a,$row[1]) == $row[1]){ session_register("user"); $user = $row[0]; session_register("passwd"); $passwd = $row[1]; header("Location: main.php"); } } echo "<font color=red>Can't login.</font>"; and I fill in the right username and password, then I can't login. I retrieve my password by: echo crypt($inputPassword); in a little script. This password I store at the users.inc at the second field. So my problem is the comparing. Is there something wrong with this script? I am not useing PHP that long... If somebody could help me, thanks! Erik Holman. -- http://www.php.net/manual/en/function.md5.php http://master.php.net/manage/user-notes.php?action=edit+28350 http://master.php.net/manage/user-notes.php?action=delete+28350 http://master.php.net/manage/user-notes.php?action=reject+28350

« previous php.notes (#41945) next »