Requesting Help with login script

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
kgscott284
Forum Newbie
Posts: 3
Joined: Fri Dec 04, 2009 4:43 pm

Requesting Help with login script

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Requesting Help with login script

Post 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
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
kgscott284
Forum Newbie
Posts: 3
Joined: Fri Dec 04, 2009 4:43 pm

Re: Requesting Help with login script

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Requesting Help with login script

Post 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.
Last edited by AbraCadaver on Thu Dec 10, 2009 1:40 pm, edited 1 time in total.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
kgscott284
Forum Newbie
Posts: 3
Joined: Fri Dec 04, 2009 4:43 pm

Re: Requesting Help with login script

Post by kgscott284 »

thats exactly what i need...

thanks alot i really appreciate it...
Post Reply