Posted by Disco Octopus on 01/31/06 02:18
gene.ellis@gmail.com wrote:
> I am using PHP to allow users to create profiles on our website and
> store them in a MS SQL database and I am wondering, how can I encrypt
> the passwords? Also, how would I be able to match the right password
> when it is time to retrieve the password from the database? Thank you
> very much for your help!
To update the password....
$encpwd = md5($_POST['userpassword');
$username = $_POST['username'];
update MYTABLE
set PASSWORDFIELD='$encpwd'
where USERFIELD='$username';
To get the record.....
$encpwd = md5($_POST['userpassword');
$username = $_POST['username'];
select * from MYTABLE
where PASSWORDFIELD='$encpwd' and
USERFIELD='$username';
--
freeball
[Back to original message]
|