Script not allowing login after generating new password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LandRuler
Forum Newbie
Posts: 4
Joined: Mon Feb 03, 2003 3:28 pm
Location: Tulsa USA

Script not allowing login after generating new password

Post by LandRuler »

Hi, I’m new in this list and to PHP and MySQL. I’d welcome any help you can give. If "newbie" questions belong in another forum, please advise.

I’m working on a simple application where a registered user submits a “forgot my password” form. The script is supposed to generate a random new password, write it to the database, and send it to the user. Then they can log in with the new password and they’re off and running.

Here’s what happens now: The password generator works fine – it creates a random string any length I want. The password field in the database gets changed – not to the new random string but apparently to an encrypted version of it via the MySQL password() function. The script returns the user a notice of the new password. BUT, login with the new password fails!

I’m reluctant to ask you to do my debugging but I’m almost brain dead after hours of trying to figure this out. Can someone suggest where I might look for the problem? I’ll include my scripts in a reply if needed.

Thanks very much in advance.

Jim
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Do you use the set password statement of mysql?
would be something like

Code: Select all

$user = 'volka' //e.g.;

$pass = md5(microtime());
$query = "SET PASSWORD FOR $user@localhost = password('$pass')";
[...]
sendUserNewPassword($user, $pass);
LandRuler
Forum Newbie
Posts: 4
Joined: Mon Feb 03, 2003 3:28 pm
Location: Tulsa USA

Post by LandRuler »

Thank you.

I performed some test sent to me by other responders and still no luck. But in the mean time I also discovered that I was passing the user results of the wrong function! I changed how I report the new password to the user and it works now.

In hind-sight it was painfully obvious. :oops:

Thank you for your time.

Jim
Post Reply