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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.