Page 1 of 1

PHP Email confirmations

Posted: Sun Jul 13, 2003 11:49 am
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.

Posted: Sun Jul 13, 2003 1:14 pm
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.

Posted: Sun Jul 13, 2003 1:47 pm
by Nitro
Thankyou very much Gen-ik. Thats exactly what I was looking for. I think I should be ok now:)