note 55941 deleted from function.md5 by victor

From: Date: Thu, 18 Aug 2005 18:11:51 +0000
Subject: note 55941 deleted from function.md5 by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93846@lists.php.net to get a copy of this message
Note Submitter: sromero(at)voie(dot)com(dot)ar ---- a simple login function with 3 privilege levels <? function logueo($usuario,$contrasena) { $admin = md5("administrador"); $super = md5("supervisor"); $users = md5("usuario"); //check if exist the user and passwords variables if (isset($usuario) && isset($contrasena)) { mysql_connect("hostmysql","usermysql","passmysql"); //query to database find the user $resultado=mysql_db_query("databasename","select * from tableofusers where usuario = $usuario"); //check if user exists by the columns number if (mysql_num_fields($resultado) < 1) { return 0;} //get fun and while it honey while ($row=mysql_fetch_array($resultado)) { if ($row["password"] == md5(contrasena)) { if ($admin == $row["priv"]) { //administrator session } if ($super == $row["priv"]) { //supervisor session } if ($users == $row["priv"]) { //user session } }else{return 0;} } } else {return 0;} } ?> this function returns 0 if user not exist o is a bad password See ya !

« previous php.notes (#93846) next »