Jump to content

Header Warning


waverider303

Recommended Posts

I get this warning when I am trying to refresh the page to a different one:

 


Warning: Cannot modify header information - headers already sent by (output started at /home/ada/public_html/v2/ada_login/main.php:9) in /home/ada/public_html/v2/ada_login/main.php on line 36

 

Here is the code:

<?php
if($session->logged_in){
header("Refresh: 3 url=welcome.php?uid=$session->userid");
        echo '<h3>Creating workspace</h3>';
echo '<img src="images/loader.gif" />';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/184585-header-warning/
Share on other sites

It is generally better to code for output buffer off, especially if you plan on selling or giving the script away. But it also depends on what you are doing, for instance, if you plan on gzipping your pages up, it would be better to have output buffer on so you can serve that out easier.

 

But for most scripts you should have it off and do proper coding where you store output in a variable and echo it out at the end of the script, so you do not mix processing with outputting, to avoid errors such as this no matter the circumstance. That and output buffering is considered a "bandaid" for solving header errors.

Link to comment
https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974487
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.