Jump to content

Problems with php header() function


tmyonline

Recommended Posts

Yeah, I know that the header() function requires that nothing be allowed to output to the browser before it.  However, if I move my header() function to the top of my code, things don't make sense because the criteria that result in using the header() function are not known yet.  For example, I need to use the header() function to re-direct the page (actually to reload itself) if users enter invalid values at the form.  But, I don't know ahead of time whether they will enter invalid values.  If I put the header() at the top of my code, I will not be able to check or detect this kind of thing.  However, if I put it in the bottom, then it complains,...

Link to comment
Share on other sites

You still need to show us some code, maybe from the start of the document to the point where the header() is executed (in its original position).

 

Without anything else to go on, try looking for: a single space or newline before your <?php opening tag. Otherwise, is this file being included/required by another php script when its being run?

 

If so, the including script might be printing output before your header script is run. Or maybe it might have the elusive whitespace before the <?php opening tag?

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.