how to - url ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
littlecoder
Forum Commoner
Posts: 26
Joined: Fri Oct 17, 2008 4:36 am

how to - url ?

Post by littlecoder »

Hi,
I want to move to another page using url when a certain condition is fulfilled . Any idea ?
Thanks in advance
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: how to - url ?

Post by Syntac »

Code: Select all

header( "Location: another_web_page.php" ); // HTTP 1.1 says header URLs should be absolute, but all or most user agents can take relative ones as well.
littlecoder
Forum Commoner
Posts: 26
Joined: Fri Oct 17, 2008 4:36 am

Re: how to - url ?

Post by littlecoder »

Hi,
Thanks for the reply...But i am getting an error : 'Cannot modify header information - headers already sent'
what shall i do ?
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: how to - url ?

Post by Ziq »

PHP Manual:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

header()

In full version of this error you can see file and line where output started
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: how to - url ?

Post by Syntac »

If you absolutely must send headers after something has been printed, use output buffering.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Re: how to - url ?

Post by Rovas »

Maybe your hosting company blocked the modifications of the headers, it happened to me too. Contact them if you don' t succeed.
I forgot you can do it in the Apache' htaccess file, read here
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: how to - url ?

Post by novice4eva »

You can use javascript too
viewtopic.php?f=1&t=89847
Post Reply