If you move the redirect to the first line of code on the page will it redirect:
<?php
header("Location: thankyou.php");
die();
?>
my guess is there is another error before the redirect preventing it from being successful. By starting on the first line and moving it down, you may be able to determine where the problem begins and then how to fix it.
If not