PHP error: Cannot modify header information


You cannot use header() once text has been output to the browser. As your header.php include presumably outputs HTML, header() cannot be used.
You can solve this in a couple ways:
  • Move the if statement above the header include (this won't work, as you've indicated in comments that header.php sets the uid session and other vital stuff).
  • Call ob_start() at the top of the script to buffer the output.

You can't issue HTTP headers after you have outputted content.

unction Redirect($url) {
        flush(); // Flush the buffer
        header("Location: $url"); // Rewrite the header
        die;
    }


function Redirect($url) {
        flush(); // Flush the buffer
        ob_flush();
        header("Location: $url"); // Rewrite the header
        die;
    }


To ensure your error reporting level is the same across environments, you can set it in your application using error_reporting() and ini_set('display_errors', 1)
Also check your .php files for any whitespace before the opening tag and after the closing tag.
In addition to the points mentioned above, ensure you are not outputting anything before the headers are set, for example the following code would produce an error similar to the one you are receiving:
echo 'Hello, World';
header('Location: http://www.somesite.com');