With all due respect this seems a little dof to me
should one not place this code in the form and associate it with the submit button, so that the user is assited before processing time is spent on opening the thankyou.php file.
The way it is now means the user must now return to the form.