Forum Moderators: coopster

Message Too Old, No Replies

Redirecting to URL in PHP

Alternative to header () function

         

aruns

7:48 pm on May 29, 2008 (gmt 0)

10+ Year Member



I'm trying to display a holding page with a message to the user while I do some backend processing, and based on the processing I decide the URL to redirect the user to.

When I tried to use the header() function, I got this message "Cannot modify header information - headers already sent".

I tried the http_redirect() function & that didnt work either - I guess my webhost php installation doesnt support this. Any suggestions on how best to tackle this?

Thanks

eelixduppy

7:54 pm on May 29, 2008 (gmt 0)



Your host should support the use of that function. The error you are receiving is just as it states - you already sent the headers so you cannot modify them anymore. In order to do this, you must first call header() before any other content is sent to the browser; this includes HTML and even whitespace. Try that and see where you get.

dreamcatcher

7:54 pm on May 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Note: As of PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.

ob_start() [uk2.php.net]
ob_end_flush() [uk2.php.net]

Should be helpful to you.

dc