jesushax Posted March 25, 2009 Share Posted March 25, 2009 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] } Quote Link to comment https://forums.phpfreaks.com/topic/151086-solved-header-sent-to-wrong-page-wierd-one-i-dont-understand/ Share on other sites More sharing options...
JonnoTheDev Posted March 25, 2009 Share Posted March 25, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/151086-solved-header-sent-to-wrong-page-wierd-one-i-dont-understand/#findComment-793692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.