Log in

View Full Version : Self Processing Forms...an the modify header error



tedteeter
06-04-2014, 12:03 AM
Greetings, June 3rd 2014
Briefly, I am utilizing "Self processing Php Forms" which I constructed a few years back and when I attempt to set a cookie I get the "Warning: Cannot modify header information - headers already sent by (output" would anyone by chance know of a way around it?...I assume that this will never be achieved since the page, header was initially loaded upon page load and the form processes cannot change the file header information. I repost information back to the form so reloading the page is out! I didn't set up sessions with the large form either?..Just looking for ideas?

Appreciatively,
Ted

fastsol1
06-04-2014, 12:43 PM
There are ways around it but the best way is to send the form data to a processing page that does not have any output on it. BUT it's impossible to give any guidance without seeing how your code looks.

tedteeter
06-05-2014, 01:56 AM
Hey thanks for the reply! It is a very large file with several form handlers etc, much to large to expect anyone to analyze it...I have thought of processing the form data externally but I would have to just pass it back an repost to the form fields. I was looking for a quick fix....perhaps there isn't one?

Appreciatively,

Beverleyh
06-05-2014, 06:00 AM
The "quick fix", although I risk having my hand slapped for making the suggestion and I know it shouldn't be relied upon because it gets you in to bad habits, is to try ob_start() at the top of your php. It's not the best practice - all the php code should come before any output (echos, prints or breakouts for HTML) but it can help make long convoluted scripts a little easier to deal with.

http://stackoverflow.com/questions/4401949/whats-the-use-ob-start-in-php and https://www.google.com/search?q=ob_start&gws_rd=ssl#q=ob_start+overcome+headers

tedteeter
06-07-2014, 01:25 AM
Beverleyh, June 6th 2014

Great! you directed me appropriately an I was able to correctly utilize the setcookie without invoking the "Header Error" However, while I was able to work around the php setcookie I still retained a javascript setcookie for purposes of a greeting should the url string not retain the correct passed greeting!...Great work! Thanks!

Appreciatively,
Ted