// Email Validation - Generating Links

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
PHPMan
Forum Newbie
Posts: 13
Joined: Thu Nov 18, 2004 8:47 am

// Email Validation - Generating Links

Post by PHPMan »

Hey when you have a script say form.htm
and a user fills it out, submits it and (formhandle.php) handles the script
(which I have those) The formhandle.php generates a username, and password for the user...they are in variables ( $username, $password )

Now my question is using the mail function of course Im sure is how Id get a validation link sent to the user...but how do I get the script to generate
a link and mail it to the user saying ::click here to activate your account::
<link>
where does the link come from, how does it work?

What Im doing now is all the data they submit in the form is going into a particular table, once they click this validation link, they are moved into the 'permanant' table (for perm. members)

Is there an easier way to do this? perhaps using an extra fieild in the databased called: temp
and when they submit they gett added with a 1 under the temp
once they click the think to validate their account, it changes too a 2?

I mean phew ;) this is hard stuff for me :( lol
Appletalk
Forum Newbie
Posts: 6
Joined: Sun Dec 19, 2004 7:23 pm
Location: Argentina
Contact:

Post by Appletalk »

For each registration you generate a identifier, that'll be in a PRIMARY KEY field in your database table.
In addition, you should have a "confirmed" field (type bool :))
When you handle the registration you send a mail to the user, saying she/he has to click in a link like:

http://www.yoursite.com/confirm.php?id=12313

In confirm.php:

Code: Select all

# Retrieve the id
if(!empty ($_GET['id'] )) {
     # First we remove slashes and other content that could be dangerous
     #
     ...
     # We select from db the id
     #
     $query = "....";
     $row = mysql_fetch_row(mysql_query ( $query ) ) );

     if( !empty ( $row ) ) {
          # We have a matching user
          # We update the field confirmed
     }
}
Note:
This pseudocode is not tested, as there may be some syntax errors..
Besides that, some other logic is missing, for example: your system should remove users that have not confirmed the account in the last 24 hours.

Hope this helps
If some part is not clear, just ask.
PHPMan
Forum Newbie
Posts: 13
Joined: Thu Nov 18, 2004 8:47 am

Re

Post by PHPMan »

Alrighty, Im going to give it a shot

Thank you very much for all your help :)
Post Reply