I am trying to show some page that automatically redirect to another page, when using header(location) I get this error:
Warning: Cannot modify header information – headers already sent by (output started at public_html/headerFile.php)
What else should I try?
The longer, and more correct way, is to reorganize your logic so that it knows that it should redirect the user before it tries outputting anything to the page. Do all of your logic first, then display.
The quick easy way around is to add
ob_start()to the beginning of your script. This turns on output buffering, so nothing gets sent to the browser until everything is finished, which means you can still modify the headers.