Re: Forwarding to another PHP page

From: Date: Fri, 09 Apr 2004 16:18:20 +0000
Subject: Re: Forwarding to another PHP page
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-182992@lists.php.net to get a copy of this message
At 11:59 09-04-2004, John W. Holmes wrote:
From: "Ash.." <equinus100@eyecaremall.com> What are the various ways of forwarding to another page. I tried header().. based on an example I found it in, but it doesnt work if I have done an include before calling the header. What are the other alternatives of forwarding. (I tried searching the PHP manual, but didnt find any clue. Nor did I come across any learn material which seemed to deal with this.) header() is the only way you're going to redirect with PHP. Alternatives include a JavaScript redirection or a meta-refresh header.
I prefer having a meta-refresh header in my template. Since the template is shared across multiple scripts, some needs to forward, some don't I use a $forward variable that contains the URL to forward to, and simply check if it's set or not in the template header... Something like: <head> <?php if (isset($forward)) { echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=$forward\">\r\n"); } ?> ... </head> the \r\n is probably irrelevant in HTML headers, but force of habit from doing MIME headers... naturally there's possible variation to this according to the actual project ... but it's how I do it ... Rene -- Rene Brehmer aka Metalbunny ~ If you don't like what I have to say ... don't read it ~ http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums @ http://forums.metalbunny.net/

« previous php.general (#182992) next »