Header Location not the best option

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
mariolopes
Forum Contributor
Posts: 102
Joined: Sun May 22, 2005 7:08 am

Header Location not the best option

Post by mariolopes »

Hi
I need to change between pages and the unique command I know is header (....) . Any other option? Header() as lot of troubles with messagens like headers already sent...
Any other options?
Thank you
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Header Location not the best option

Post by AbraCadaver »

If you want to redirect to another page that's about your only option. There is a meta refresh solution but it's not portable and not recommended.

header() doesn't have problems, your script has problems if you output anything and then call header() because headers are sent when you output to the browser and you can't send more headers after the data. That's why they are called "headers".

If your code is correct, headers won't cause any problems. In the rare event in which things may be output before a header call, you can use output buffering.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply