Jump to content

Recommended Posts

have an activation.php page which only has one task

 


$code = $_GET['code'];

$query = "SELECT * FROM tablename WHERE activationcode = $code";
$result = mysql_query($query) or die ("Error in query" . mysql_query());
$row = mysql_fetch_assoc($result);

if (mysql_num_rows($result) == 1)
{
$id = $row['idtable'];
$update = "UPDATE tablename SET active =1 WHERE idtable = '$id'";
mysql_query($update) or die ("Error in query" . mysql_query());
echo "Your account is now active";
header(location: where you need it to be forwarded to;
exit;
}
else
{
header(location: login page);
}

 

then in the email have the activation number be a link to this page setting itself as the code part of the address

 

hope that helps

as i couldnt get yours to work i improvised with this:

 

$activate = $_GET['activate'];

$query = "SELECT active FROM users WHERE code = $activate";

if ($query == 0)
{

$update = "UPDATE users SET active =1 WHERE code = $activate";
mysql_query($update) or die ("Error in query" . mysql_query());

print ("<br /> \n");
print ("<center> \n");
print ("$username, your account is now active, please login on the homepage. \n");
print ("<br /> \n");
print ("<br /> \n");
print ("<a href=\"index.php\">Home Page</a> \n");
print ("</center> \n");

}

 

But for some reason i keep getting an error.

 

any help would be greatly appreciated.

 

~ Chocopi

Thanks for your help.

 

you wouldnt believe it but i forgot to add the page_header so it wasnt connecting to the database  :-[

 

however, its still not working properly as it is not picking up the username variable or the the actual activation variable.

 

i think it might be because i am just loading activation.php as i dont know how to get it to work when its activation/


please help,

thanks

~ Chocopi

yea but its not working.

 

if you could, can you tell how i can get it to recognise that it is the user.

 

the way i would like it to work is that the user clicks on the link root/activation/

 it loads up the activation page and activaters their account

for that to happen then the link they click must also pass either their activation code in the url such as

 


location.href="http://www.yourPage.com/activate.php?code=123456789";

 

where 123456789 is the activation code you emailed them, then using something like the code I sent originally (admittedly flawed with mysql_query() instead of mysql_error()) which searches the table for that code, pulls the id and updates the the table with the user in it to 'active' for that id.

Thanks  ;D

 

as im still a n00b with php would be possible if you could write something for me?

 

if you can then the activation code would be $activation table would be 'users' and the coloum to update would be 'active'

 

Many thanks,

 

~ Chocopi

<?php
$activation = $_GET['activation']; //get the activation code from the url

$query = "SELECT * FROM users WHERE activationcode = '$activation'"; //first see if it is a real activation code
$result = mysql_query($query) or die ("Error in query" . mysql_error());
$row = mysql_fetch_assoc($result);

if (mysql_num_rows($result) == 1) //if one row is returned then it is real
{
$id = $row['idtable']; //get the id of the table for that activation code
$update = "UPDATE users SET active=1 WHERE idusers = '$id'";
mysql_query($update) or die ("Error in query" . mysql_error());

header(location: ; //send them to the page you want them as an active user
exit;

}
else
{

header(location: ; //send them where you want them to go as a none active user
exit;

}
?>

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.