How to prevent the browser from filling out form data when navigating back

I have a php form that submits data to a database. When the form has been successfully completed and the data submitted, the form is cleared due to page refresh. When the user clicks the back button in the browser, the data is returned.

Is there a php function that will prevent caching of this data?

+4
source share
2 answers

There is no reliable method, since the behavior on the back is browser dependent. Moreover, if someone comes back through history, and you change what happens, you change history. Metaphysical "woah!" from this aside, this is not a great idea.

What is the problem besides questions related to resending? If the problem with the re-submission form is a problem, you need to deal with it in case of a quick double-click on the submission too late. Include the hidden nonce value (UUID is good), save nonce with your record no matter what it is, and reject duplicate notes.

+2
source

autocomplete = "off" in the input fields of your forms?

+3
source

All Articles