Forum Moderators: coopster

Message Too Old, No Replies

how to use crypt for login?

         

hsceeus

8:02 am on Mar 29, 2006 (gmt 0)

10+ Year Member



i doing a login page, and i want to encrypt the password that i already register... i can do that by using the crypt() function in PHP..

My problem now is how can i match the encrypt password in the database with the password that key in by user when they want to login to the page?

omoutop

8:13 am on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



//
// Taken from manual.
//
To authenticate against a stored crypt in MySQL, simply use:
SELECT ................
AND Password=ENCRYPT('".$_POST['password']."',Password)

jatar_k

8:35 am on Mar 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



just use md5() to encrypt the pass

then take the use input, md5 that and compare to the stored md5 string

omoutop

11:05 am on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Jatar is correct, md5() offers better algorithm for encryption.

In md5 case you will have something like:
SELECT .. FROM.. WHERE ...
AND password=password('".$_POST['password']."')