the best practice or atleast the practice that i follow whenever i m working with PHP and mysql, is that i have my form and database script in separate pages. So lets say the page with form is called index.php and the page with which stores the value in the database is called register.php.
Then I use jQuery AJAX in index.php to send my form values in a GET or POST asynchronous request to register.php and let it save the values in the database and send an e-mail to the user. The beauty of it all is that you don't have to show i.e. redirect to the register.php page at all, you can do all this without ever leaving the index.php page. Also your javascript could really benefit from jQuery have a look at:
Jquery[
^].
the problem with your code seems to be the fact that both your form and PHP script is on the same page and there is no check for a postback to self. And in the absence of a "action" attribute in form tag, the default is to postback to itself and that's why when u refresh the same values get re-posted.
Hope this helps.
EDIT: Also, use Regular Expressions for input validation and don't defer the validations until the user clicks the submit button. Try doing as soon as the control loses focus (jquery will manifest its power here and you will love it) :)