Re: redirecting to another page
| From: | Chris Shiflett | Date: | Sat, 25 Sep 2004 19:31:22 +0000 |
| Subject: | Re: redirecting to another page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197828@lists.php.net to get a copy of this message | ||
--- AMC <aboehme@netgate.net> wrote:
> What code do I use to redirect a user to a different page in php?
There are several methods, but my favorite is to use a Location header
which also changes the response status code. This method is transparent to
the history mechanism, so users can still click the Back button.
header('Location: http://example.org/');
Another method is to use the Refresh header, which also allows you to set
a timer for the redirect. One disadvantage is that it can prevent a user
from using the Back button.
header('Refresh: 0; url=http://example.org/');
There are also client-side methods of redirecting the user, but this is a
PHP list. :-)
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming December 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/