Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End php form issue Reply To: php form issue

#176729
__
Participant

So cool!!! I added the error reporting

SO cool. Troubleshooting FTW. : )

I changed the location header … But it didn’t fix the problem.

No, I didn’t expect it to. That was kind of a “side note.” But it was a good idea to change it anyway.

Warning: Cannot modify header information - headers already sent

“headers already sent” means that there was already regular output sent to the browser — e.g., HTML, text, or even a blank line. HTTP responses look like this:

HTTP/1.1 200 OK
Header_Name: Value
Header_Name: Value

<!doctype html>
<html>
<head>
  <meta charset=utf-8>
  <title>my web page</title>
</head>
<body>
  <p>See all the headers up there?
  <p>…no?
</body>
</html>

I’m sure you recognize the second part — it’s a normal HTML document. The first part (before the blank line) is where all the HTTP headers go. That’s where you put the response code, Location header, cookies, and so forth. Yes, it really is just plain text that is sent before the “body” of the response.

The moment you send regular output to the browser —anything, even a blank line— PHP has to send all of the header information, because the regular output must go after, in the body. From this point forward, it is too late to add any more headers: they are “already sent.”

SO, you’ve got to figure out where that output is, and then either (a) remove it, or (b) move your call to header somewhere before that output.