Hello,
This should be done on the server side, like so:
Immediately after you insert the date, redirect the user to a third page using the HTTP "Location" header so when they refresh the page they'll get the third page and nothing happens (because the second page added the data to the database and moved on the the third).
You could also redirect the user with JavaScript on the page that loads after the form is submitted. Send them to a "thank you" page or something. You could also try to set the current url to the current url (yes, it's redundant, i know) which just causes the page to reload without doing anything so when the user refreshes, the last action will be performed by the browser: load the url without sending anything to the server.
If you don't understand, let me know and I'll post an example.
Hope this helps,
Tom