Jump to content

Redirecting


Glese

Recommended Posts

I do know that nothing should be printed out before a header() redirect, yet this error message:

 

Warning: Cannot modify header information - headers already sent by

 

Is pointing to a meta tag, why does a meta tag become considered as a print out?

 

The meta tags are as usually located in between the header tags of the whole website.

 

What would you rather recommend in this case to accomplish a redirecting after a successful log in?

Link to comment
https://forums.phpfreaks.com/topic/252318-redirecting/
Share on other sites

It's still rendered by PHP.  Remember: PHP is what is generating the HTML sent to the browser.  Anything, even a blank space, that's rendered before you attempt to redirect will result in that error.  The key is to organize your script(s) properly:

 

ALL PHP processing (store results in variables and determine if you need to redirect)

|

|

|

|

V

HTML output

 

Meshing chunks of PHP with HTML is a bad way to go.  At most, you should only have if/else-conditionals and loops embedded in your HTML.  All other processing should be done beforehand.

Link to comment
https://forums.phpfreaks.com/topic/252318-redirecting/#findComment-1293496
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.