Page 1 of 1

Requesting Help with login script

Posted: Fri Dec 04, 2009 4:49 pm
by kgscott284
Essentially I have implemented a login script that is very basic and sends the user a password via email using md5 hash...obviously most people are not going to want to remember these passwords so i was wondering if someone could help me with a change password function...or point me somewhere that can help...I have searched google for tutorials and even looked through hotscripts but have been unsuccessful...Thank you for your time.

Re: Requesting Help with login script

Posted: Fri Dec 04, 2009 4:59 pm
by AbraCadaver
Normally you let the user pick their password 'mypassword12' or generate one with letters/numbers, etc... and store as a hash (md5() hash, whatever) in the DB. Then when the user logs in they supply their password 'mypassword12' and you md5() hash it and compare with the DB value. They don't have access to the hash of their password.

-Shawn

Re: Requesting Help with login script

Posted: Fri Dec 04, 2009 5:02 pm
by kgscott284
sorry i didn't explain well, what i meant was the password is automatically generated...e.g.

Code: Select all

 
substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);
 
I just need to figure out how to make a change password script so users can set their own passwords after receiving the confirmation email

Re: Requesting Help with login script

Posted: Fri Dec 04, 2009 5:09 pm
by AbraCadaver
Just have a form where they supply their generated password and new password. Post it, and:

Code: Select all

"UPDATE users_table SET password = '" . mysql_real_escape_string($_POST['new_password']) . "' WHERE username = '$username' AND password = '$old_password'"
Not sure what you need.

Re: Requesting Help with login script

Posted: Fri Dec 04, 2009 5:16 pm
by kgscott284
thats exactly what i need...

thanks alot i really appreciate it...