CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Activate my account~

Print topic Send  topic

Author Message
lin

Posts: 5
Posted: 03/24/2004, 10:16 AM

I have built a member area with login function, once new member register for their account, it will send e-mail to member automatically with a link, that is for activation purpose, just like what I did in this forum!

I know how to send mail automatically to member, however, I don't know how to provide a activation linkage in email so that new member can click for for activation~

Is there any php source file provide this function? or just use codecharge studio to do so?

ps. I use mysql as database

Thank you very much!

View profile  Send private message
SPF
Posted: 03/29/2004, 4:43 PM

This is a multi-part message in MIME format.
--------------070705030101060700040802
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

lin wrote:

> I have built a member area with login function, once new member register for their account, it will send e-mail to member automatically with a link, that is for activation purpose, just like what I did in this forum!
>
> I know how to send mail automatically to member, however, I don't know how to provide a activation linkage in email so that new member can click for for activation~
>
> Is there any php source file provide this function? or just use codecharge studio to do so?
>
> ps. I use mysql as database
>
> Thank you very much!
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

I have attached a chapter of the PHP Cookbook which I have modified/used
to do just what you are looking to do and it works quite well. Take a
look at it and try to apply it to your own code. To get you started,

1.) Place this function in your Common.php:

// Generate an activation code
function act_code(){
$verify_string = '';
for ($i = 0; $i < 16; $i++) {
$verify_string .= chr(mt_rand(32,126));
}
return $verify_string;
}

2.) Create 2 fields such "act_code" and "activated" (1 or 0) in your
members table.

3.) Make the two above fields hidden on reg your form, with "activated"
set to "0".

4.) Add a before show event (or before insert, etc.) to "Retrieve value
of control".
- Set the control to your "act_code" field name
- Set the type to Expression
- Set the Value to 'act_code()' (without quotes)


5.) From here, you will just need to retrieve the "email" and "act_code"
values from the table for the new user using CCDlookUp, or by using
CCGetFromGet depending on when you send the e-mail message.

Once you have them, it is up to you as to how you email them but here is
one example which uses PEAR::Mail (http://pear.php.net) as described in
the PDF, which also can be added to Common.php:

///////////////////////////////////
//// Send activation e-mail
///////////////////////////////////
function notify_user($email, $verify_string){
$verify_string = urlencode($verify_string);
$safe_email = urlencode($email);
$verify_url = "http://". $_SERVER['HTTP_HOST'] . "/activate.php";
$mail_body=<<<_MAIL_
To $email:
Welcome to [your website name]!
Please click on the following link to verify your account creation:

$verify_url?email=$safe_email&verify_string=$verify_string

If you do not verify your online account within fourteen(14) days, it
will be
automatically removed from our system.
Thank You,
Your Company
_MAIL_;
mail($email,"Online Account Verification",$mail_body);
}

You can do this in a variety of ways, this is just one example. As an
After/Before Insert event, you could just call this functionm weith the
two variables pulled from the DB to send the activation notice.


6.) Ok, the email is sent, but you need one more page. "activate.php". I
created this page and added two grids (not using the builder, just plain
ol grids). Name one of them "Activated" and the other "ActivationError"
or whatever you want to name them.

7.) In both Grids, remove the table created by CCS containing the
default fields.

8.) Create your messages for both grids. Example:
<!-- BEGIN Grid Activated -->
Your success message HTML Here
<!-- END Grid Activated -->

<!-- BEGIN Grid ActivationError -->
Your activation Error Message Here
<!-- END Grid ActivationError -->


9.) Create a before show event for the page (Custom Code) and use
something similar to this:

//Custom Code
// -------------------------
global $Error;
global $Activated;

////
// Find the member who is requesting activation
////
$_REQUEST['safe_email'] . " AND act_code = " .
$_REQUEST['safe_verify_string'];
$safe_email = addslashes($_REQUEST['email']);
$safe_verify_string = addslashes($_REQUEST['verify_string']);
$member = CCDLookup("members", "member_id", "email = '" . $safe_email .
"' AND act_code = '" . $safe_verify_string ."'", "DByourdb");

// Was this a valid request?

if ($member != ""){
$SQL = "UPDATE members SET activated = '1' WHERE member_id = " . $member;
$db = new clsDByourdb();
$db->query($SQL);
unset($db);
$Error->Visible=false;
$Activated->Visible = true;
} else {

// It wasn't?

$Activated->Visible = false;
$Error->Visible=true;
}
// -------------------------
//End Custom Code

You're done. Hope this helps, Good luck!

Steve F.
SPF
Posted: 03/30/2004, 8:36 AM

I replied to the newsgroup, and apparently, the attachment didn't fly.....

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.