Im trying to work on a script for authentication for administrator rights.
I have a user table in my db that contains these rows:
userid , username , password.
The password in the table has been encrypted using md5.
Im having trouble creating the script for logging in, and taking their non-md5 password and matching it up with to the one in the db.
Anyone has an example of making a simple login script using md5 for logging in?
Or a basic explanation on how to compare what is inputed by the user and compare it to the one in the db?
Question about md5()
Moderator: General Moderators
if the password in the db is stored as md5
hth
Code: Select all
// we have no auth as of now
$ok = false;
// if md5() value of supplied password = the db (md5) password then we have auth
if (md5($passwd) == $db_passwd) {
/* the password matches */
unset($ok);
$ok = true;
}
if ($ok) {
//auth successfull
} else {
//auth failed
}