PHP Email confirmations

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
Nitro
Forum Newbie
Posts: 5
Joined: Sun Jul 13, 2003 11:49 am
Location: London, England

PHP Email confirmations

Post by Nitro »

Hi, could someone please tell me how to make one of those e-mail confirmations scripts, so that when I user signs up to a site, they are e-mailed a 10 digit code of numbers, that they must submit somewhere on the site to confirm there account. Hopefully you understand what I mean. If not, I'll explain further.

Thanks.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

If you know PHP this should be a pretty easy thing to do really.

On the PHP page that the form is submitted to is where you will need to put the email stuff.

First of all create your four digit code....

Code: Select all

<?php
$nums = Array('0','1','2','3','4','5','6','7','8','9','0');
shuffle($nums);
$code = $nums[0].$nums[1].$nums[2].$nums[3];
?>
That's that done.

Now you will need to store that number in a database along with the username and password etc.

To send an email use....

Code: Select all

<?php
mail($to,$subject,$body,$from);
?>
....and remember to include a link to your 'code entry' page and remember to include the code number.

When the user enters their code number, username, and password on the 'code entry' page just check the info against the data you stored in the database when the email was sent.
Nitro
Forum Newbie
Posts: 5
Joined: Sun Jul 13, 2003 11:49 am
Location: London, England

Post by Nitro »

Thankyou very much Gen-ik. Thats exactly what I was looking for. I think I should be ok now:)
Post Reply