View previous topic :: View next topic |
Author |
Message |
crs992 -
Joined: 15 Jun 2005 Posts: 32
|
Posted: Fri Mar 17, 2006 12:29 am Post subject: php header(Location: ) |
|
|
is there anyway that I can make something like this:
Code: | <?
$url = $_GET['url'];
echo'<a href="/">return to home page</a>';
header("Location: $url");
exit;
?> |
work?
i wnat it so when you go to mysite.com/redir?url=http://www.google.com it shouws google and a link back to my site but i keep getting this error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Abyss Web Server\htdocs\redir\index.php:1) in C:\Program Files\Abyss Web Server\htdocs\redir\index.php on line 3
please help.
thanks. _________________ http://crs992.bounceme.net:8080/ |
|
Back to top |
|
|
Yami King -
Joined: 08 Sep 2005 Posts: 120
|
Posted: Fri Mar 17, 2006 12:33 am Post subject: |
|
|
the header function must be the first function called |
|
Back to top |
|
|
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Fri Mar 17, 2006 12:39 am Post subject: Re: php header(Location: ) |
|
|
Code: | <?
$url = $_GET['url'];
header("Location: $url");
?> |
No as the error tells you, the header command must be the first instruction returned to the browser. The "header location" command redirects the users browser to the specified address in the arguments, and appears in the html head section.
More info on the header command is available here: http://uk.php.net/manual/en/function.header.php
To achieve the effect you are after you could use frames.... _________________ Olly |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Fri Mar 17, 2006 9:01 pm Post subject: Re: php header(Location: ) |
|
|
crs992,
headers must be changed and sent before sending any output (with echo or any other method). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
danbradster -
Joined: 07 Jul 2006 Posts: 1
|
Posted: Fri Jul 07, 2006 1:26 am Post subject: |
|
|
You can use ob_start(); at the top of your code instead of having the header first. |
|
Back to top |
|
|
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Fri Jul 07, 2006 3:08 am Post subject: |
|
|
Server seems to be offline at the moment. Bummer!
-------------------------
BTW, this is the first month of hosting my sig (picture below) and it has received over 2700 hits! Awesome! _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
|
|