Page 1 of 1

Header Function Question

Posted: Tue Aug 31, 2010 3:59 pm
by neesley
I have a page built of php includes. One of which is a submit form along with a script that posts to itself.

The problem is that since the content is in an include and the parent page already has header info, I can't use the header function to redirect after the form has been processed. One solution of which I can think is to simply remove the script to a separate file. This seems rather inelegant compared to having everything in one document.

Thoughts? Thanks.

Re: Header Function Question

Posted: Tue Aug 31, 2010 4:27 pm
by AbraCadaver
As long as the processing script doesn't output anything then you can use header(). Don't include the form if you don't need it:

Code: Select all

if(!isset($_POST['submit'])) {
   //include form
} else {
  //include form processing script
}

Re: Header Function Question

Posted: Tue Aug 31, 2010 5:12 pm
by neesley
Thanks man. What a big help!

I was echoing a line of text as well. Once that was out it worked fine.