Page 1 of 1

Help me to find error in my code

Posted: Wed Aug 26, 2009 8:43 pm
by gimpact
Hello,

I have done this many times but I dont know why this time this is not working. Any one?

Code: Select all

<?php
function activateClass($email,$ID){
    // Opend database connection
    include ("DBConnect.php");
   //Check if the user already exist
    $getData = "SELECT * FROM account WHERE email = '$email'";
    $getData2=mysql_query($getData) or die("Could not query for user");
    $getData3=mysql_fetch_array($getData2);
    if((strlen($getData3['email'])>0)){
        // When no user found
        header("Location:http://www.z.com/candidates/signup/activate/status/?ref=UserNotFound");
    }else{
        // USER FOUND, Check for Activation_code
        $ID2 = $getData3['activation_code'];
        if($ID2 != $ID){
            header("Location:http://www.z.com/candidates/signup/activate/status/?ref=InvalidURL");
        }else{
            // Found match for email and activation code
            // Get activation status
            $activation = $getData3['activation'];
            if($activation == no){
                // Activate account
                $sql = "UPDATE account SET activation = 'yes' WHERE email='$email'";
                $sql1 = mysql_query($sql) or die("Could not activate you");
                header("Location:http://www.z.com/candidates/signup/activate/status/?ref=AccountActivated");
            }else if($activation == yes){
                header("Location:http://www.z.com/candidates/signup/activate/status/?ref=ActiveAccount");
            }else{
                header("Location:[b]http://www.z.com/candidates/signup/activate/status/?ref=UnknownError[/b]");
            }
        }
        
    }
    mysql_close();
} // End of function
 
?>
 
The above bold error is what I am getting. More over in the display page I am getting this error.

Code: Select all

<?php
// When the account has been activated
$ref = $_POST['ref'];
 
if ($ref == UserNotFound){
    $displayMessage = "No such user account found";
}else if($ref == DatabaseError){
    $displayMessage = "Sorry, account cound not be created due to a database error";
}else if($ref == AccountActivated){
    $displayMessage = "Congratulation, your account has been successfully activated. Please login now";
}else if ($ref == ActiveAccount){
    $displayMessage = "Your account is already active";
}else if ($ref == InvalidURL){
    $displayMessage = "Sorry, this url is not an authenticate URL";
}else if($ref == UnknownError){
    $displayMessage = "Server returned unknown error";
}else{
    $displayMessage = "[b]You are not authorized to view this page[/b]";
}
 
 
print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
print "<html>";
print "<head>";
print "<meta http-equiv='Content-Type'content='ext/html charset=UTF-8'";
print "<title></title>";
print "</head>";
print "<body>";
print "<b>".$displayMessage."</b>";
print "</body>";
print "</html>";
?>
Any help will be appreciated. Thank you.

Re: Help me to find error in my code

Posted: Wed Aug 26, 2009 9:47 pm
by requinix
1. You need to start using quotes on your strings.

Code: Select all

if($activation == no){ // bad
if($activation == "no"){ // good
 
}else if($activation == yes){ // bad
}else if($activation == "yes"){ // good
 
// and so on
2. print $activation before it gets into the if blocks.

3. Things passed through the URL are in $_GET, not in $_POST.