MD5 is one way encryption. once yo uencrypted the password you cannot decrypt it.
so, when you store MD5(ed) password in database then next time when user comes in and enters password then you have to MD5 that password and compare it with the password in database. MD5 always generates the same encrypted string for the same string. i mean if
$string = 'passsword';
echo MD5($string);//and say it is 123bandasd
then in future if you again do
$string = 'passsword';
echo MD5($string);//then it'll be same as 123bandasd
so for your passwords you do
PHP Code:
$username = 'username';
$password = 'enterd by user';
$md4password= md5($password);
//connect to database
$result = mysql_query("select password from table where username='$username'") or die;
$row = mysql_fetch_array($result);
if($row['password']==$md5password)
{
echo 'you are authorized';
}
else
{
echo 'you are NOT authorized';
}
Hope this might help
Bookmarks