-
mySql PASSWORD function
If I send a users password to a database table using:
PASSWORD('$userpwd');
when they first register. If I want to check that that user and their password is valid at another login time will I just be able to compare the password they enter the next time they log on with the one in the database to authenticate them. If not how do I do the following:
I want to store user's passwords encrypted in a database but I need to compare these encrypted passwords with user when they login at another time.
Sorry if this sounds confusing.:devil:
-
encrypt both
When they log in next... encrypt the password they entered. Compare this encrypted password to the already encrypted password in your database.
-
there are other functions other than password() that you could use
like encode() and encrypt()
-
i'd use PHP's or MySQL's md5().
-
If I read the question correctly, you just need to do this:
PHP Code:
<?PHP
$sql = "SELECT * FROM db.users WHERE password = PASSWORD('$pwd');"
$result = mysql_query($sql);
?>