NYCPHP Meetup

NYPHP.org

[nycphp-talk] online password replacement

Allen Shaw ashaw at iifwp.org
Fri Mar 5 16:42:32 EST 2004


Okay, I'm thinking to do something like this:

I need a 3-column table, something like this:

CREATE TABLE `pwd_request` (
  `requestid` int(11) NOT NULL auto_increment,
  `userid` int(11) NOT NULL default '',
  `pwd` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`requestid`)
) TYPE=MyISAM AUTO_INCREMENT=1;

* user requests password replacement
* password is reset to random value, which is stored in a new record,
    along with userid of this user
* get pwd_request.requestid for that new record
* using email address on file, a link like this is sent to the user:
  <? echo
"http://mydomain.com/password.php?id=$new_request_id&pwd=$rand_pwd&userid=$u
serid"; ?>

When the user accesses that given URL
* password.php queries for a record in pwd_request matching on 3 fields
* if record is found, delete that record and display form to receive new
password
    (If no record is found, display error message and accept no changes.
This
    way we prevent the link from being used twice.)
* apply new password to user's actual record.

The mechanics of this definitely make sense to me, and it seems safe enough.
Thanks Dan, Chris, and others for your input.

- Allen

> --- Dan Cech <dcech at phpwerx.net> wrote:
> > A fairly standard approach is to simply generate a new random password
> > and send it to the email address you have on file.
>
> You probably also want to have a unique link in the email (or some similar
> mechanism) that the user needs to visit in order to activate the new
> password. Otherwise, random people can reset your users' passwords, which
> is a hassle for them.
>
> Chris




More information about the talk mailing list