Jump to content

activation code


dean7

Recommended Posts

hi,

 

Can some1 please help me so when some1 register's up to my website they  have to activate it.

I have this so far but it dont send anything to there inbox:

 

$md5pass = md5($_POST['pass2']);
$activ_code = rand(1000,9999);
$server = $_SERVER['HTTP_HOST'];
$host = ereg_replace('www.','',$server);
mysql_query("INSERT INTO users
              (`user_email`,`user_pwd`,`country`,`joined`,`activation_code`,`full_name`)
			  VALUES
			  ('$_POST[email]','$md5pass','$_POST[country]',now(),'$activ_code','$_POST[full_name]')") or die(mysql_error());

$message = 
"Thank you for registering an account with $server. Here are the login details...\n\n
User Email: $_POST[email] \n
Password: $_POST[pass2] \n
Activation Code: $activ_code \n
____________________________________________
*** ACTIVATION LINK ***** \n
Activation Link: http://$server/activate.php?usr=$_POST[email]&code=$activ_code \n\n
_____________________________________________
Thank you. This is an automated response. PLEASE DO NOT REPLY.
";

mail($_POST['email'] , "Login Activation", $message,
    "From: \"Auto-Response\" <notifications@$host>\r\n" .
     "X-Mailer: PHP/" . phpversion());
unset($_SESSION['ckey']);
echo("Registration Successful! An activation code has been sent to your email address with an activation link...");	

exit;
}	

?> 

Link to comment
https://forums.phpfreaks.com/topic/145393-activation-code/
Share on other sites

And i have a activate.php file with this in it:

 

<?php 
session_start();
include ('dbc.php'); 

if (!isset($_GET['usr']) && !isset($_GET['code']) )
{
$msg = "ERROR: Invalid code...";
exit();
}

$rsCode = mysql_query("SELECT activation_code from users where user_email='$_GET[usr]'") or die(mysql_error());

list($acode) = mysql_fetch_array($rsCode);

if ($_GET['code'] == $acode)
{
mysql_query("update users set user_activated=1 where user_email='$_GET[usr]'") or die(mysql_error());
echo "<h3>Thank you </h3>Email confirmed and account activated. You can <a href=\"login.php\">login</a> now..";
} else
{ echo "ERROR: Incorrect activation code...not valid"; }






?>

 

But then thats still dont send them nothing into there inbox

Link to comment
https://forums.phpfreaks.com/topic/145393-activation-code/#findComment-763307
Share on other sites

Here is a zip with some really old code that should do the job

 

And the SQL for the table

CREATE TABLE `users` (
  `userid` int(25) NOT NULL auto_increment,
  `first_name` varchar(25) NOT NULL default '',
  `last_name` varchar(25) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `username` varchar(25) NOT NULL default '',
  `password` varchar(32) NOT NULL default '',
  `sex` varchar(6) NOT NULL default '',
  `user_level` enum('0','1','2','3') NOT NULL default '0',
  `signup_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_login` datetime NOT NULL default '0000-00-00 00:00:00',
  `activated` enum('0','1') NOT NULL default '0',
  PRIMARY KEY  (`userid`)
);

 

I have got some update code but that's tailored to my needs which is better but this should be a starting point

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/145393-activation-code/#findComment-764164
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.