Jump to content

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


jesushax

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.