You can't send some HTML headers, then send some HTML, then send some more HTML headers.
If you want to do header commands after you have already sent <html>, then you need to use ob_start and ob_flush to start and stop output buffering. Output buffering lets you do headers anywhere and they are still sent at the top BEFORE your html. Of course then the page won't display until you ob_flush.