Re: http header
| From: | Chris Shiflett | Date: | Fri, 16 Apr 2004 21:41:41 +0000 |
| Subject: | Re: http header | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183703@lists.php.net to get a copy of this message | ||
--- Elfyn McBratney <elfyn.mcbratney@emcb.co.uk> wrote:
> > Is the following code the best way to redirect someone to a
> > different page using PHP?
> >
> > <?php
> > header("Location: http://www.yahoo.com");
> > ?>
>
> That's also known as "breaking the back button", but is the only way
> to do it in PHP. A better way to redirect someone (and keep the back
> busson working) is to use the meta html tag.
I'm not sure what you mean by breaking the back button. I think you're
talking about when you click back and are immediately forwarded again,
which is annoying for users. This is typically the case of a Refresh
(whether HTTP header or http-equiv meta tag) set with a 0 second delay.
So, I think you've got it backward, because the Location header does not
have this problem, since the redirect is transparent to the history
mechanism.
Also, when you're using PHP, it is rare that it is going to be better to
use a meta tag to emulate an HTTP header. PHP has the header() function,
and it can set real headers.
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/