Using PHP mail; getting Header warning

You can’t use header in the middle of a page, content has already been sent to the browser, so that means headers were already sent.

Look at the code in the myriad of form plugins out there to see how they handle this- hook an action before the template is loaded and do your form processing and checking there.