Re: PHP Redirect in the middle of code?
| From: | Steve Edberg | Date: | Mon, 10 Sep 2001 15:11:43 +0000 |
| Subject: | Re: PHP Redirect in the middle of code? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66762@lists.php.net to get a copy of this message | ||
Right off the top of my head, you have three options that I can see:
(1) Rewrite the code to avoid any output before the redirect.
(2) Use output buffering (available only in PHP4). I haven't used this, but check out
http://www.php.net/manual/en/ref.outcontrol.php
(3) Use a META REFRESH tag. For example:
<META HTTP-EQUIV="refresh" CONTENT="1;page.php">
where 1 is the time (in seconds) before you want the redirect, and 'page.php' is where you want the redirect to. Of course, this tag needs to be in the <HEAD> section, so it might not help you much.
As far as I know, though, cold fusion's <cflocation> tag only works because CF does output buffering implicitly. So, I'd guess you need to do option (2).
-steve
At 10:37 AM -0400 9/10/01, Andrew Penniman wrote:
I am trying to figure out how to use PHP to redirect the user to a new location *after* processing and most likely outputting a bunch of code. Because this redirection would happen late in the game I can't use header("Location: ".$redirect_to); I come from a ColdFusion background and am used to CFAS' <cflocation> tag. Does PHP have an equivalent function? I am really hoping not to use JavaScript, I want this redirection to happen at the server and not the client.-- +------------------------ Open source questions? ------------------------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +----------- http://pgfsun.ucdavis.edu/open-source-tools.html -----------+