Going straightly to my question, I have read about encrypting password while registering the user.Till here im able to register users with encrypted password by using PASSWORD('$PASS');
where $PASS
is the users password. My sql table details
is as follows :-
FNAME
LNAME
EMAIL
PASS // USED ENCRYPTION AS PASSWORD('$PASS'); HERE.
I can't understand how to decrypt the password & use futher in my code i use the following code to use decrypt the password but its not working. !
<?php
$EMAIL = $_POST['email'];
$PASS = $_POST['pass'];
mysql_connect('host', 'user', 'pass');
mysql_select_db('userdb');
$results = mysql_query(sprintf("SELECT FNAME,LNAME,EMAIL,PASS FROM `details`
WHERE PASS=PASSWORD('$PASS')",
mysql_real_escape_string($EMAIL))) or die(mysql_error());
while($row = mysql_fetch_assoc($results))
{$rows[1] = $row;}
if(!($_COOKIE['pass'] == $rows[1][PASS]))
//cookie is set while registering user , which is the decrypted(original) value of password.
{ die("Error occured"); }
else { echo "Password entered is correct"; }
////.....my further code here.
?>
Its showing Error occured
on the page, which means the password is incorrect. I Also add that this code was working correctly before encryption of password in database.Im new to encryption process ,Your little help is needed which will help me to learn more. Thanks in advance.