Anything not within <?php...?> tags will generate output, which will cause headers to be sent, so you need to move the doctype declaration to a point after you do your header() call (and also make sure there is nothing -- including whitespace -- before the opening <?php tag).