header() won't work if anything has been sent to the client already (be it html or PHP warnings, which are plain html as well)
another way is to use Javascript, which can be put anywhere in a page, but requires the page to load first
<script language="Javascript">window.loaction/href="mynewpage.php";</script>