I'm wondering if a php error is occuring.
Change the line for the redirect:
$GoToPage = "thanks.php";
to:
$GoToPage = "";
then add the following code at line 1:
<?php
error_reporting(E_ALL);
ini-set('display_errors','on');
?>
report back any errors that are displayed on testing.