Jump to content

malformed header - not consistently, though.


red green

Recommended Posts

Hi,

I'm helping a friend with a site, and we've got a script that is giving us a 500 internal server error, but only in one specific case.  Apache's log says it's a malformed header, so I've traced it down to a single header statement within a function in that script.

The confusing part (for me) is that there are several conditional statements in that function, each of which has it's own header statement.  Each of them work properly with no error.  Only in this one specific case does the script fail on us.

Here's some pseudocode of the function in question:
[code]
if (registration is successful)
  {
      set session variable: username;
      set session variable: successful registration;
      header("Location: user_cp.php?mode=register");
  }
else if (form had errors)
  {
      set session variable: array of form values;
      set session variable: array of form errors;
      header("Location: user_cp.php?mode=register");
  }
[/code]
If the form had errors, the page is redirected correctly without errors.  But if the registration goes through, we get the 500 internal server error and Apache logs a malformed header. Any ideas?

Thanks in advance,
Mike
Link to comment
https://forums.phpfreaks.com/topic/29478-malformed-header-not-consistently-though/
Share on other sites

Got it...

Turned out to be an include file that we had forgotten about.  There is a function there to send a welcome message to a newly registered user, and that was causing the problem.

Lesson learned:  make sure you debug your include files, too.

Thanks!
Mike

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.