if a user submitted the form and the user accidentally refreshed the page, it will insert the user's information twice to the database.

you mean redirect the page after the submit button was clicked?