Redirection 
Author Message
 Redirection

My ISP doesn't allow me to fopen (etc) to a web page - and I don't
know if my question will be related somehow - anyway ...

how would I get a php script to forward a use to another page - like
document.location in javascript?

Thanks,

pemo



Sun, 31 Jul 2005 06:28:04 GMT  
 Redirection


Quote:
> My ISP doesn't allow me to fopen (etc) to a web page - and I don't
> know if my question will be related somehow - anyway ...

> how would I get a php script to forward a use to another page - like
> document.location in javascript?

Look at the header() function.  It has documentation on doing this.

--
David Risner



Sun, 31 Jul 2005 06:47:15 GMT  
 Redirection


Quote:

> My ISP doesn't allow me to fopen (etc) to a web page - and I don't
> know if my question will be related somehow - anyway ...

> how would I get a php script to forward a use to another page - like
> document.location in javascript?

> Thanks,

> pemo

http://www.php.net/manual/en/function.header.php

or

<?php
header("Location: http://www.example.com/"); /* Redirect browser */
exit;                 /* Make sure that code below does
                         not get executed when we redirect. */
?>



Sun, 31 Jul 2005 06:58:13 GMT  
 Redirection


{
        header("Location: http://www.microsoft.com");

        exit;                                    

Quote:
}

I want the code above to redirect someone from Microsoft to
Microsoft.com - however, the code doesn't work at all.

Any ideas?

pemo



Thu, 04 Aug 2005 02:30:39 GMT  
 Redirection
It probably has to do with one (or both) of the following:

1) $IP doesn't have a valid IP address.  Use $REMOTE_ADDR in place of $IP
(or use that global var to set $IP).
2) DNS on your server is not working properly.  You can test this quickly
and easily by putting the folloing in a test php script:

<?php

  print $REMOTE_ADDR;
  print "<P>";
  $r = gethostbyaddr($REMOTE_ADDR);
  print $r;
  print "<P>";

?>

When loading this script in a browser you should see your host IP and your
hostname.  If you don't see your hostname then DNS on the server your PHP is
hosted on is not resolving IP addresses for you.

There is also the additional possiblity that employees browsing the Internet
go through a corporate firewall that doesn't have "microsoft" in the
external public name.

HTH,
Patrick


Quote:


> {
> header("Location: http://www.microsoft.com");

> exit;
> }

> I want the code above to redirect someone from Microsoft to
> Microsoft.com - however, the code doesn't work at all.

> Any ideas?

> pemo



Thu, 04 Aug 2005 13:14:46 GMT  
 Redirection

Well, the test went ok, but using 'header' still didn't work - went
for this in the end ...

function redirect($url)
{
        echo "<script>window.location.replace(\"".$url."\")</script>";

Quote:
}

pemo

On Sat, 15 Feb 2003 23:14:46 -0600, "Patrick Altman"

Quote:

>It probably has to do with one (or both) of the following:

>1) $IP doesn't have a valid IP address.  Use $REMOTE_ADDR in place of $IP
>(or use that global var to set $IP).
>2) DNS on your server is not working properly.  You can test this quickly
>and easily by putting the folloing in a test php script:

><?php

>  print $REMOTE_ADDR;
>  print "<P>";
>  $r = gethostbyaddr($REMOTE_ADDR);
>  print $r;
>  print "<P>";

>?>

>When loading this script in a browser you should see your host IP and your
>hostname.  If you don't see your hostname then DNS on the server your PHP is
>hosted on is not resolving IP addresses for you.

>There is also the additional possiblity that employees browsing the Internet
>go through a corporate firewall that doesn't have "microsoft" in the
>external public name.

>HTH,
>Patrick




>> {
>> header("Location: http://www.microsoft.com");

>> exit;
>> }

>> I want the code above to redirect someone from Microsoft to
>> Microsoft.com - however, the code doesn't work at all.

>> Any ideas?

>> pemo



Thu, 04 Aug 2005 17:36:44 GMT  
 Redirection
The header won't work if you have printed any other items to the HTML
stream.  The header() function should come before ANY and ALL output (even
regular HTML that is not in your PHP code, even the opening <HTML> tag).

Patrick


Quote:

> Well, the test went ok, but using 'header' still didn't work - went
> for this in the end ...

> function redirect($url)
> {
> echo "<script>window.location.replace(\"".$url."\")</script>";
> }

> pemo

> On Sat, 15 Feb 2003 23:14:46 -0600, "Patrick Altman"

> >It probably has to do with one (or both) of the following:

> >1) $IP doesn't have a valid IP address.  Use $REMOTE_ADDR in place of $IP
> >(or use that global var to set $IP).
> >2) DNS on your server is not working properly.  You can test this quickly
> >and easily by putting the folloing in a test php script:

> ><?php

> >  print $REMOTE_ADDR;
> >  print "<P>";
> >  $r = gethostbyaddr($REMOTE_ADDR);
> >  print $r;
> >  print "<P>";

> >?>

> >When loading this script in a browser you should see your host IP and
your
> >hostname.  If you don't see your hostname then DNS on the server your PHP
is
> >hosted on is not resolving IP addresses for you.

> >There is also the additional possiblity that employees browsing the
Internet
> >go through a corporate firewall that doesn't have "microsoft" in the
> >external public name.

> >HTH,
> >Patrick




> >> {
> >> header("Location: http://www.microsoft.com");

> >> exit;
> >> }

> >> I want the code above to redirect someone from Microsoft to
> >> Microsoft.com - however, the code doesn't work at all.

> >> Any ideas?

> >> pemo



Fri, 05 Aug 2005 01:56:26 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. IO redirection in gawk with cygwin

2. Redirection to a file within action part..

3. Ignoring I/O errors in output redirection

4. Redirection not working

5. SED multiple file redirection?

6. File redirection

7. input redirection

8. a2p and redirection

9. Problems with output redirection in gawk

10. Redirection PB 3.2

11. redirection file ??

12. Redirection File - will this cause problems?

 

 
Powered by phpBB® Forum Software