Some browsers even doesn't not ask this confirmation at all, it just resend the input data again and again. At that time if input values validation isn't proper in the backend then it create duplicate records.
For example, When we see warnings like "Do not click back button or refresh the page" in an online payment system, we may feel bit nurveous and uneasy. Following scenarios makes post data resubmitted again and again:
Reloading the page again and again after form submission
Clicking back button then forward button in browser
Returning back to form in case of any redirection after form submission and then clicking submit button to resend the data
How to avoid form submission on page reload:To avoid this issue we need to follow POST – REDIRECT – GET method along with avoiding browser cache. That means,
- First we need to tell the browser do not cache this page
- After successfully processing POST data, we need to redirect the user to same page in the backend. So browser consider this as fresh request and we can add another set of values.
Below I've given html - php example which implements above method. Save this code in htdocs directory as post.php