php email activation

Soldato
Joined
22 Nov 2007
Posts
4,332
Im trying to get user's to verify their accounts. What i've done so far is let the users enter their details and send off the details to the database. At the same time ive tried to put an mt.rand() to generate a number and put it in the "activation code" column. At the same time i use the mt.rand function to send a number to their email. The first problem is in the database the number keeps coming up as 0 , and also i'll need to make sure the number in the db is the same one as the one being emailed. Im new to php so im not sure if im going the right away about this. Can anyone help?

Thanks
 
Stuff like this usually goers along the lines of:


  1. Users enters detail to create new account
  2. Data saved into database and flagged as unauthorized.
  3. At same time, a unique key is inserted (could use an md5 of their session id E.g. $key = md5( session_id() ); This is inserted at same time as point 2.
  4. Again at same time an email is sent to the users email with an activation code E.g. ocuk.com/verify.php?email=[email protected]&key=dfgfhksdgfhsdgfhgsdfgsdg473743hn423uy4t23
  5. When the user clicks this links you should check that the email exists, that the account isn't already validated, that the email/token pair match and that correct token is present. If all these are true update the account flag and redirect the user.
Make sure you have your fields types correct too - for the key you could just use a varchar - length depends on your key length.
 
Back
Top Bottom