cancel
Showing results for 
Search instead for 
Did you mean: 

SQL / PHP if NULL show else

Former Member
0 Kudos
2,183

We are trying to complete / fix the below code, We cant seem to do the following.

  • Check if 'Check_Activation' is set to 'NULL' within the Database
  • IF value is NULL direct the user to one of the forms (1,2,3)
  • And finally if the 'Check_Activation' has already been activated and isn't 'NULL' prevent user from accessing one of the 3 forms.

I know its basicly there but we can't seem to figure out the final bug.

Please have a quick look at the code below and if anyone notices anything that isn't right please advice us.

http://pastebucket.com/27517 [CODE]
http://awkreativ.com/freelance/analogue/barrio_activation/ [WEBSITE]

<?php

    $username = $_POST['username'];
    $activation_code = $_POST['activation_code'];
    $activation_codeurl = $activation_code;
    $usernameurl = $username;

    $db_host = "localhost";
    $db_name = "aardvark";
    $db_use = "aardvark";
    $db_pass = "aardvark";

    $con = mysql_connect("localhost", $db_use, $db_pass);
    if (!$con){
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db($db_name, $con);

    $checkcustomer = mysql_query("SELECT `Check_Activation` FROM `members` WHERE `Username` = '".$username."' & `Activation` = '".$activation_code."'; ");

        $array = mysql_fetch_array($checkcustomer);
        if (is_null($array['Check_Activation']))  {
                $username = substr($username, 0, 1);
                if($username == '1') { 
                    $redirect_url='form-one.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;
                } elseif($username == '2') { 
                    $redirect_url='form-two.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;              
                } elseif($username == '3') { 
                    $redirect_url='form-three.php?membernumber='.$usernameurl.'&activation_code='.$activation_codeurl;
                }
                header("Location:". $redirect_url);
        } 
        else 
        {
    ?>
VolkerBarth
Contributor
0 Kudos

How is that question related to the SQL Anywhere database system?

MarkCulp
Participant
0 Kudos

Agreed. This looks like this should be a PHP question... or at least direct it at a mysql or LAMP forum.

Accepted Solutions (0)

Answers (0)