Re: Problem with redirect
| From: | Bunmi AKinmboni | Date: | Fri, 18 Mar 2005 02:35:47 +0000 |
| Subject: | Re: Problem with redirect | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25768@lists.php.net to get a copy of this message | ||
Thanks guys.
As suggested, I had previous sent an echo command.
Regards,
Bunmi
George Pitcher wrote:Bunmi, I haven't seen any replies, though you may have had some off-list. Somehere in your code, you are outputting data. You cannot have any output before a header(). Even a testing echo would have this effect. Hope this helps.. George in Oxford
Michael Quinn wrote:Jason Barnett wrote:Because you have already sent output to the browser before calling the header() function. Maybe you have <head /> tags somewhere before your code or something. There is a lazy workaround below for you. if (isset($HTTP_SERVER_VARS['HTTPS']) && ($HTTP_SERVER_VARS['HTTPS'] == "on")) { $protocol = "https://"; } if (preg_match("#^/#", $url)) { $url = $protocol.$server_name.$url; } else if (!preg_match("#^[a-z]+://#", $url)) { $url = $protocol.$server_name.(preg_replace("#/[^/]*$#", "/", $HTTP_SERVER_VARS["PHP_SELF"])).$url; } echo "<script>location.href='" . $url . "';</script>"; } exit; }
Bunmi Akinmboni wrote:I develop under windows. Why will my redirect be giving this error: Warning: Cannot modify header information - headers already sent by (output started at.... Search the archives for your error message, you will find the answer. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins