Please attach the page instead of using copy/paste so that I can open it more easily when looking at your code.
Your redirects aren't working because of the spaces in your code.... any time you have:
?>
<?php
it needs to be:
?>
<?php
blank lines of code prevent redirects from working in php.