Hi All,
I have a few scripts whereby once a form is submitted (and info uploaded and stored in the db), it redirects to another page.
The problem is, that once I uploaded it to my clients server, I get this error;
Warning: Cannot modify header information - headers already sent by (output started at /path/to/mainframe_distributors_add.php:19) in /path/to/add_dist.php on line 79
Now, I know that header() must be before any output, but the site is in frames and I need the code where it is, it also worked fine on my Linux server.
I trie ob_start() - but that caused more errors than it fixed....
Anyway, heres my code;
***********************************
$insertGoTo = "mainframe_distributors_thanks.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
***********************************
Thanks for any help.
Christian
First thing I registered was that you are enclosing the HEADER statement with the } and it's nowhere opened. Well, maybe there's just a cut of your code, so in that way it's ok.
Second, why you are using sprintf in a HEADER statement? That's something I've never seen before. I think this may cause the problem, because sprintf output the text to a browser and therefore it must send header the information before it can print anything out.
Why don't you simply use: header("Location: ".$insertGoTo); ?
regards
CyberGhost