You can run PHP within HTML. But you need to be cognizant of the fact that once anything is sent to the browser (which includes HTML text not within <?php tags), headers are sent at that point, as the headers must be sent before the content is. Therefore, any PHP functions called later in the script which attempt to create or alter HTTP headers will not work.
The options are (1) reorganize your script so that anything that affects HTTP headers (e.g.: session_start(), setcookie(), header(), etc.) are executed before any output is sent, or (2) use output buffering by sticking the following at the very beginning of the main script (with nothing before it, including blank lines or spaces):
<?php
ob_start();
?>