Jump to content

Recommended Posts

Hi,

 

I need to implement an E-Mail confirmation system on the actual login system registration.

 

I don't have sure on how to do it, please give me some clues.

 

My actual users table is like this:

CREATE TABLE `users` (
`UserID` INT(25) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Username` VARCHAR(65) NOT NULL ,
`Password` VARCHAR(32) NOT NULL ,
`EmailAddress` VARCHAR(255) NOT NULL
);

 

I'am thinking in send an e-mail with a link to the user activate their account.

 

My question... How to implement a system like that?

 

I will have to create a field "Active" the values should be "0" for Inactive and "1" for Active. But how to generate a key to send by URL to the user activate?

 

PS: Please tell me if I don't explained well, my english is poor.

 

Best Regards,

André.

Not really that much related to MySQL specifically...

 

To create a random string you can just do e.g. md5(microtime()); or you could write a function:

function generateRandomString($length = 50)
{
$chars = array_merge(range('a', 'z'), range(0, 9));
$charsMax = count($chars);

$string = null;
for ($i = 0; $i < $length; $i++) {
	$string .= $chars[rand(0, $charsMax)];
}

return $string;
}

 

Anyway, just create a two fields: is_activated (tinyint(1) default 0) and activation_code (char (length=whatever you want))

 

So put the activation code in the row and send the code to their email. Then they can verify using that and you can set is_activated to 1. When logging in you just need to check if is_activated=1.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.