Forum Moderators: coopster

Message Too Old, No Replies

How do I create a PHP and MySQL change password form with MD5?

PHP Password Change Form MD5

         

cphillips

2:56 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



Hi,

Summary:
I a beginner with PHP and I am creating a secure customer portal using php and MYSQL I am using logon scripts and storing passwords with MD5 encryption.

I am able to:
get the password to be stored into the database as MD5 and the user can log in sucessfully.

My problem:
Comes when I am trying to make a password reset form where I (the admin) can change the users password to a temporary password (cant figure out how to do this), then the user can logon with the temporary password and change the temporary password to a new one.(cant figure out how to do this either). The variable does hold the hash, but its not being updated in MySQL.

The Code:
I am trying to use the following command with no luck:

$query = "UPDATE user SET `password`='$newpassword' WHERE id='$id'";

$result = mysql_query($query);

Am I doing somthing wrong? I have tried many differnt version and ways to do this with none being sucessful.

Thank you for your time!

dreamcatcher

3:57 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi cphillips,

I assume you are sending data from a form? Do you have register globals OFF? Also, use mysql_error() to see if the query is failing in any way.

So, try this:

$query = "UPDATE user SET `password`='".$_POST['$newpassword']."' WHERE id='".$_POST['id']."'";
$result = mysql_query($query) or die(mysql_error());

dc

cphillips

5:59 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



Thank you very much!

You saved me a lot of headache!

You are awesome!

dreamcatcher

6:09 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are awesome!

Well, thanks for the nice words, but I think 'awesome' is a tag for some of the more knowledgeable guys here.

Glad I could help. :)

ergophobe

6:52 pm on Nov 10, 2005 (gmt 0)

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



Don't believe him. He's awesome.

jatar_k

6:59 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



after 2 1/2 years dc we all know you have good chops

cphillips

7:07 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



ha ha,

This is such a GREAT forum.

Thanks again!

dreamcatcher

9:14 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ergophobe,jatar_k,

Its nice to be considered so highly in such esteemed company. Thanks.

:)