That's exacly what the problem is...
If you want to do this in the same page posted to itself, you need to look at something like:
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
(Add a hidden field)
<input type="hidden" name="confirm" value="y">
Then you need to code something to check to see if it exists and proceed from there....
If (!isset($confirm)):
// Nothing really needed here if the confirm variable is not set
Else:
include('thanks.php');
Endif;
This is kind of simplistic, but I think you get the point...