Page 1 of 1

headers already sent error

Posted: Sun Sep 17, 2006 7:21 am
by duncan
How could I rewrite this code so that while the page is redirecting, a message such as "please wait... you are being redirected" is shown without a "headers already sent" error?

Using this buffer method does not work... The page is redirected without errors but without the "please wait" message.

I don't want to use meta refresh nor javascript because these can be disabled in the browser options.

Code: Select all

<?php
ob_start();

echo "<p>please wait... you are being redirected</p>";

header("Location: somepage.php");

ob_end_flush();
exit;
?>

Posted: Sun Sep 17, 2006 9:26 am
by feyd
Output buffering is not an answer to this "problem."

viewtopic.php?t=1557

Posted: Thu Sep 21, 2006 2:42 pm
by duncan
I don't understand how that url is related to php header.

Posted: Thu Sep 21, 2006 2:51 pm
by Luke
use a meta refresh... but then supply the user with a link in case meta refresh doesn't work... that's kinda the standard way of doing things. You can't echo out data and then send a header. It doesn't work that way... a header is exactly that, a header, so it would be send BEFORE any data. There is no way to send data before headers... EVER

Posted: Thu Sep 21, 2006 4:08 pm
by feyd
duncan wrote:I don't understand how that url is related to php header.
Sorry, posted the wrong link

viewtopic.php?t=1157