Okay that worked. But now I have a new problem, first here is the WHOLE code:
if(!isset($id) || !isset($aid) || empty($id) || empty($aid))
{
echo 'You have reached this page via a faulty activation link. Please contact the administrator immediately at: <a href="mailto:' . $admin_email . '">' . $admin_email . '</a>';
}
elseif(isset($id) && isset($aid))
{
$sql = "SELECT ";
$sql.= "t1.status, t2.activateid ";
$sql.= "FROM ";
$sql.= "users t1, temp t2 ";
$sql.= "WHERE ";
$sql.= "t1.uid = t2.uid ";
$sql.= "AND ";
$sql.= "t1.uid = '$id' ";
$sql.= "AND ";
$sql.= "t2.uid = '$id'";
$query = mysql_query($sql) or die(sql_error());
while($row = mysql_fetch_array($query))
{
$status = $row['status'];
$activation_id = $row['activateid'];
}
if($status == '2')
{
echo 'Your account has already been activated. Please <a href="' . $full_domain . 'login.php">click here</a> to login.';
}
elseif($activation_id != $aid)
{
echo 'You have reached this page via a faulty activation link. Please contact the administrator immediately at: <a href="mailto:' . $admin_email . '">' . $admin_email . '</a>';
}
elseif($status == '1' && $activation_id == $aid)
{
unset($sql);
unset($query);
$sql = "UPDATE ";
$sql.= "users ";
$sql.= "SET ";
$sql.= "status = '2' ";
$sql.= "WHERE ";
$sql.= "uid = '$id'";
$query = mysql_query($sql) or die(sql_error());
unset($sql);
unset($query);
$sql = "DELETE ";
$sql.= "FROM ";
$sql.= "temp ";
$sql.= "WHERE ";
$sql.= "uid = '$id'";
$query = mysql_query($sql) or die(sql_error());
echo 'Your account has been successfully activated. Please <a href="' . $full_domain . 'login.php">click here</a> to login.';
}
}
If the users is successfully activated, then their activation code and id is deleted from the temp table, so they don't try and activate again. If they go try and activate again, I check their status (if it's 1, they aren't, if it is 2, then they are), even if the user is activated, it totally skips the IF() that determines if the status is 2, and displays the error message that is to display if the activation id is not the same as the one in the link.
I think this happens because the first time the account is activated, the record in the temp table is deleted, and then when the users goes to activate AGAIN, the code tries to check the database for activation id instead of the status... why?