Jump to content
Larry Ullman's Book Forums

How To Fit Different Parts In Site Modularization?


Recommended Posts

I am trying to write a contact form. To do so, I have parted form in contactform.html and posted it to email.php. I'm using modularizing concept to make the site. There is a configuration file, header and footer files and modules. header file includes encoding using header() and starts session.

 

I'm including a link to contactform.html in index.php. Clicking that link loads contactform.html nicely. Once that form is filled and submitted, it shows error "headers already sent - output started at .. email.php. (email is sent out correctly.)

 

I have not included configer and header,footer file in contactform.html.

I have included configer and header,footer file in email.php.

 

Now I know, that we cannot include session start and header function, two times like this. Header file has actually started the session already as the error says. But, if I omit header and footer file from email.php, I lose all the formatting. And if I keep those files, it gives error of headers already sent.

 

The script runs well on my local machine. And the above problem comes on the live site.

 

contactfrom.html is loading nicely in content area with all the formats, but email.php is not loading into content area. I think this is the problem. But how to solve it?

Link to comment
Share on other sites

I was sending header with encoding type of utf8 in header file. And that was the reason, of "headers already sent .." error. I found following info on php.net.. and it solved my problem.

when the encoding of your script file needs to send some headers just after your script starts to execute,

 

this happens mostly with the scripts using normal utf8 encoding.

 

To overcome the issue, use utf8(without BOM) encoding provided by notepad++ and most modern editors. Using utf8 encoding and cookie based sessions, will result in headers already sent by error.

Link to comment
Share on other sites

 Share

×
×
  • Create New...