Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2005, 01:51 AM
Registered User
 
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spbharti
Default how to send activation link with e mail

When a user registers with my site, I want an email to be sent to the user with an activation code or a custom link in order to verify that the email submitted is valid before their account becomes active. I would imagine there are others out there who have the same requirement. Any assistance would be appreciated. Thanks
 
Old December 27th, 2005, 06:01 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

It is very easy. You're storing the 'verification code' in db. And use PHP mail() to send a link to PHP script in your Web site that checks/tallies that 'verification code'. Easy!

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old December 28th, 2005, 09:17 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Activation Code:
<?php
$chain="";
$arra_codesASCII=array();
for($i=ord(0);$i<=ord(9);$i++) $arra_codesASCII[]=chr($i);
for($i=ord("a");$i<=ord("z");$i++) $arra_codesASCII[]=chr($i);
for($i=ord("A");$i<=ord("Z");$i++) $arra_codesASCII[]=chr($i);
for($i=0;$i!=128;$i++) $chain.=$arra_codesASCII[array_rand($arra_codesASCII)];
?>
Store the code in the database with there username obviously ;) then send them an email:
<?php
$headers = 'From: webmaster@companyname.com' . "\r\n";
$headers.= "MIME-version: 1.0\n";
$headers.= "Content-type: text/html; charset= iso-8859-1\n";

$message = "Thank you to register with (company name)<br>\n (2nd line) <br>\n In order to activate your account please click here:<br>\n
<center><a href=\"http://websiteaddress/reguser.php?verify=".$chain."&mail=".$useremail)." &web=0\">Activation</a></center> <br>\n
Thank you for taking the time to register to the (company name) Website. <br><br>\n\n Please do not reply to this email has the mailbox isn't monitored.<br><br><br>\n\n\n<center> - The Webmaster (company name) - </center><br>\n";

mail($useremail,'title', $message, $headers);
?>

create a page:
http://websiteaddress/reguser.php
the data are in 'verify'

:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
send mail chavakoti BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 September 4th, 2007 05:03 AM
Cannot send mail rajanikrishna JSP Basics 3 March 17th, 2006 01:39 AM
e-mail a link p2ptolu Classic ASP Databases 1 June 17th, 2005 06:58 PM
Not able to send a mail hums .NET Framework 2.0 5 November 16th, 2004 03:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.