are you outputting anything on this page?
If not, you can put your redirect header right down the bottom after doing all your stuff up the top, there are no problems with doing that.
e.g
<?
do php stuff here
some more stuff here
db queries, inserts, deletes etc here
all done...
Header("Location: thankyou.php");
?>
A