depends how you have set up your form but you could do it this way using headers..
Form will say
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD="POST">
i.e. shows itself then you would have an if statement which says when clicked on submit goto the thanks page which would be..
if ( isset ( $submit ) ) at top of page to show that when clicked do the following (insert form detail into database etc)
then after sql statement
echo("<P>Error adding your details at this time.</P>" . mysql_error());
Hope that this helps can post full form if this isn't clear