Sunday 2 October 2011

How to make account registration with account activation script in PHP

This is a basic and simple user account registration script with account activation script, written in PHP and MySql.

This is a link, which comes from user email, when the user click on itt, then the link goes and redirect to this script.
http://xyz.com/activate.php?key=true&p=fgdsfdjhfyuiobmjioujnllshgfuropvn

Make a page named it as activate.php and paste below stated php code
if($_GET['key'] == true)
{
$key = $_GET['p'];
$sql = "SELECT * FROM users WHERE user_key = '" . $key . "'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_affected_rows($result) > 0)
{
$sql = "UPDATE users
SET user_key = '', user_active = '1'
WHERE user_key = '" . $key . "'";

$result = mysql_query(sql) or die(mysql_error());

if($result)
{
$_SESSION['PROCESS'] = $lang['Account_activated'];
header("Location: ../index.php");
}
else
{
$_SESSION['ERROR'] = $lang['Key_error'];
header("Location: ../index.php");
}
}
else
{
$_SESSION['ERROR'] = $lang['Invalid_key'];
header("Location: ../index.php");
}
Related Posts Plugin for WordPress, Blogger...