Home>Article>PHP Framework> Thinkphp tips to prevent repeated form submissions
During development, if a form is added or modified, after completing the database operation in the background, we set it not to jump to other pages, or to return to this page. At this time, click the browser's back button before submitting or refreshing the page. , will cause the form to be submitted repeatedly, that is, this record will be added or modified twice.
The reason that causes the form to be submitted repeatedly is that the form submitted for the first time will be cached in the memory until the page is submitted next time or the page is closed or redirected to other pages. disappear. When the self-call returns, the data in the memory is still there. At this time, the submitted code in the page can still detect the submitted value, which will cause the effect of repeated submission.
You can use the following methods to solve it:
Method 1: The simplest: After the page is submitted, go to another page instead of this page. For example, for example, your page address is
http://yourdomain.com/User/Index/login
Then the form action address of the page can be another processing address, such as