Re: Simple redirect from PHP not POSSIBLE ???
| From: | Lars Torben Wilson | Date: | Fri, 27 Oct 2000 18:16:32 +0000 |
| Subject: | Re: Simple redirect from PHP not POSSIBLE ??? | ||
| References: | 1 2 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969332678@lists.php.net to get a copy of this message | ||
Chris Boer writes:
> How do I do a redirect from within a php script to another HTML page..
>
> Header($location) does not work..
>
> Greetz Chris
Just for the record, this isn't the right list for general PHP
questions--it's for discussion amongst the documentation team
on...well, documentation-related stuff. :) You probably want
php-general. Check out http://www.php.net/support.php
for signup.
Anyway, the above is indeed the way to do it. If it didn't work, then
one of several things may have happened:
o What was in $location? The format is "Location:
http://www.somewhere.com"
o If there was *any* output before the header() call, it would fail
unless you're using output buffering. Headers have to be sent
before 'normal' output--it's the way HTTP works. If you echo
anything to the browser, or even have include()d or require()d
files with any blank lines or anything like that outside of the
<?php and ?> tags, the header() would fail.
o Maybe the browser just isn't following.
We'd need a lot more information (a short script which reproducibly
doesn't work, OS, server, browser, etc) before making a complete
diagnosis, but the first 2 points above are by far the most common
reasons for this not to work. The third is pretty far-fetched--almost
every browser in existence today AFAIK supports the Location: header.
Hope this helps,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+