Jump to content

Some help needed


Yogiz

Recommended Posts

Hi guys,

 

Was wondering if someone could provide me with some guidance as I'm new to php on how to write a password reminder script.

 

At the moment I have username (sha1) password and e-mail stored in mysql database, how do I extract the password from the database when it uses sha hash and e-mail it to the user?

 

Thanks in advance.

 

Yogiz

 

 

Link to comment
https://forums.phpfreaks.com/topic/92973-some-help-needed/
Share on other sites

You don't.  When the user says they lost a password, you generate a random, temporary password and email it to them.  Any other way would be a completely pointless use of a hashing/encryption method.

 

A random password could be generated like this:

- Edited to change something I didn't like about the method I chose the first time.

<?php
function random_password($length=16) {
     $chars = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9));
     $string = '';
     for ($i = 0; $i < $length; $i++) {
          $string .= $chars[array_rand($chars)];
     }
     return $string;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/92973-some-help-needed/#findComment-476371
Share on other sites

INSERT INTO // database

 

Use mySQL commands to enter the generated pass into database, then retreive the info from DB, and design a little email script.

 

Look for tutorials, you are trying to do some basic stuff, I actually believe I've seen some things you're looking for.

 

If I find some, I'll letcha know.

Link to comment
https://forums.phpfreaks.com/topic/92973-some-help-needed/#findComment-476461
Share on other sites

Same way you registered their password except a little different. Create a Reset Password page, have them enter their username or email and it verifies the email is there (SELECT * FROM table WHERE username = $username) or email then if its present you will run the function as a variable even $newpass=random_password(); posted above and UPDATE table SET password = '$newpass' WHERE username = '$username'

Link to comment
https://forums.phpfreaks.com/topic/92973-some-help-needed/#findComment-477229
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.