Page 1 of 1

header redirect not working.

Posted: Thu May 16, 2002 6:44 pm
by vertige
header("Location: http://www.example.com/"); exit;

does nothing for me. I have placed the code at the very top of my template right after the <?PHP

When i access the page all I get is a popup error message "Document contains no data. Try again later.. blah, blah, blah

I'm running netscape 4.7.
PHP 4.1, Webstar on OSX.

Thanks

Posted: Thu May 16, 2002 6:56 pm
by hob_goblin
is there a point in putting exit?

header("Location:) not working

Posted: Thu May 16, 2002 7:05 pm
by vertige
exit or no exit it won't work

Posted: Thu May 16, 2002 7:07 pm
by hob_goblin

Code: Select all

<?
header("Location: http://www.example.com");
?>
hmm, if that doesn't work, I have no clue.... I don't know anything about use on different OS's...maybe one of the guru's will reply :-/

Posted: Thu May 16, 2002 9:11 pm
by fatal
To send out headers, the have to be the first thing sent on the page. I learned that from trying to make a page that was restricted access, eventually i found out that headers have to be the first thing sent. Or else you get errors for the header line of code.

http://www.php.net/manual/en/function.header.php
From the manuel:

Note: The HTTP status header line will always be the first sent to the client, regardless of the actual header() call beeing the first or not. The status may be overridden by calling header() with a new status line at any time unless the HTTP headers have already been sent.