php - headers sent??

I get this:

Warning: Cannot modify header information - headers already sent by (output started at /home/rkassoc/public_html/Houston/save_to_session.php:65) in /home/rkassoc/public_html/Houston/post_form.php on line 76

Attached is post_form.php & save_to_session.php

How does it think line 65 of save_to_session.php (the closing php tag) is sending a header?

How do I fix?

Richard KortsAsked:
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
This has been a common problem for many years, so much so, that we have articles here at E-E explaining it and showing how to get past the issues!

Using the "close PHP"  tag is a well-known antipractice (see #14).  Don't do that any more!

TL;DR: Learn about ob_start().
Richard KortsAuthor Commented:

I actually thought about you and your comment (on some other question) about the closing php tag.

I'll try it tomorrow. I'm about 98% sure that will do it.

Dave BaldwinFixer of ProblemsCommented:
And turn on 'error_reporting' in 'post_form.php'.  Always.  And 'save_to_session.php' is saving a lot of &_POST data to $_SESSION variables without doing any checking.  If one of the indexes for the &_POST data is missing, it will cause an error by sending an error message to the browser before your 'header' statements at the end of 'post_form.php'.
Mukesh YadavFull Stack DeveloperCommented:
Try this ;)

Just remove closing PHP tags from save_to_session.php
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.