Jump to content

[SOLVED] header sent to wrong page... wierd one i dont understand


Recommended Posts

hi all,

 

my code is below

 

ive commented out the mysql for now, cos i dont want it adding to the db

 

but whats happening is if i comment out the line in red the redirect in orange works

 

but if i have the redirect in red on, then it cancels out the redirect in orange

 

if you get me?

 

can anyone tell me why?

 

Thanks

 


$email = $_POST["Sect1_6"];
list($name, $domain) = explode("@", $email);

$error = mysql_query("SELECT `Sect1_6`,`CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error());
$errorID = mysql_fetch_array($error);
$emailcheck = $errorID["Sect1_6"];

list($name, $domaincheck) = explode("@", $emailcheck);

if ($domaincheck == $domain) {
[color=orange]header("Location: /new_directory/completed.php?ID=".$errorID["CompanyID"]."");[/color]
}

$posts = $_POST;
unset($posts['password']);
unset($posts['password2']);

for($i=1; $i<=21; $i++) 
{ unset($posts['T'.$i]);  }

$SQL = "INSERT INTO tblDirectory2 (";
foreach($posts as $key=>$value){
    $SQL .= "`$key`, ";
}
$SQL .="`Sect1_2`,`password`) VALUES (";

foreach($posts as $key=>$value){
    $SQL .= "'$value', ";
}

$const = "T" ;

for ($i=1;$i<=21;$i++){
   $var = trim($_POST[$const.$i]) ;
   if(!empty($var)) {
     $trades .= $_POST[$const.$i] . "," ;
   }
} 

$SQL .="'".mysql_escape_string($trades)."','".md5($_POST["password"])."')";

//echo $SQL;

//mysql_query($SQL) or die (mysql_error());

$Company = mysql_query("SELECT `CompanyID` FROM tblDirectory2 WHERE `Sect1_6`='$email'") or die(mysql_error());
while ($ID = mysql_fetch_array($Company)) {
[color=red]header("Location: /new_directory/regform_sect2.php?ID=".$ID["CompanyID"]."");[/color]
}

header should be followed by exit()

If you want the script to stop processing and redirect the user you should use the following


header("Location:index.php");
exit();

// this code will not be executed
$x = "Hello World";
print $x;

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.