could be a php error causing the redirect to fail. try adding the following code at line 1 to turn on error reporting:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
?>
instead of pasting the code into a pdf file, please attach the php file to your message