Jump to content



Photo

How To Fit Different Parts In Site Modularization?


  • Please log in to reply
3 replies to this topic

#1 sonal

sonal

    Advanced Member

  • Members
  • PipPipPip
  • 122 posts

Posted 28 February 2012 - 1:42 AM

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?
  • 0

#2 Jonathon

Jonathon

    Advanced Member

  • Members
  • PipPipPip
  • 1,025 posts

Posted 28 February 2012 - 4:08 PM

I can't be sure from the description, but one reason can be using a closing php tag on included files.
  • 0

#3 sonal

sonal

    Advanced Member

  • Members
  • PipPipPip
  • 122 posts

Posted 29 February 2012 - 2:56 PM

Thanks. No, there is no closing php tag on included files.
  • 0

#4 sonal

sonal

    Advanced Member

  • Members
  • PipPipPip
  • 122 posts

Posted 29 February 2012 - 3:27 PM

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