Changing 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
roadkillguy
Forum Newbie
Posts: 7
Joined: Sun Feb 22, 2009 11:26 am

Changing URL

Post by roadkillguy »

This is probably a very simple question, but how do I get another web page using php?

I have some code that executes some logic, and needs to get back to index.php when its done.

Are there any simple functions?
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Changing URL

Post by watson516 »

You want to redirect?

Code: Select all

header('Location: index.php')
roadkillguy
Forum Newbie
Posts: 7
Joined: Sun Feb 22, 2009 11:26 am

Re: Changing URL

Post by roadkillguy »

That doesn't seem to work. It gives a warning stating that php cant modify the header information because it was already sent.

Warning: Cannot modify header information - headers already sent by (output started at /home/david/public_html/PHP/Test.php:3) in /home/david/public_html/PHP/Test.php on line 19
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Changing URL

Post by watson516 »

that statement has to be at the top of the page before any output (including html). Or you could use ob_start() I hear.
Post Reply