How to avoid repeated submission of your form

xiaoxiao2021-03-06  41

Have you encountered the "repeated submission" problem? It is not difficult to solve this problem. There is a simple method to avoid submission of the same form.

First, we can define a session variable to save a submission serial number of a form. Here I am defined as "$ userlastaction". Then add an Hidden variable in the form to set the value to $ USERLASTACTION 1:

>

Finally, determine if the form has been submitted before processing the submission:

IF ($ LastAction> $ userlastaction and infutisvalid (...) {

$ UserlastAction ; // Serial number plus 1

// Processing form data

}

original:

Avoid Multiple Form Submissions

Submitted by: Douglas E. COOK

Date: 07/26/00 19:46

Does your database suffer from "duplicate post" SYNDROME? The cure isn't too difficult. Here is a Simple Way to prevent Users from subsmitting The Same form Multiple Times.

. First, declare a session variable to store a serial number for each form I call mine "$ userLastAction." Then, in every form where duplicate submission is a problem, include a hidden field, and set the value to $ userLastAction 1:

& li; Input Type = Hidden Name = LastAction Value = >

Finally, Verify That The Form Has NOT BEEN Previously Submitted Before Acting on The Submission:

IF ($ LastAction> $ userlastaction and infutisvalid (...) {

$ USERLASTACTION ; // Increment Serial Number

// Act ON Form HERE

}

Translated from: PHPBUILDER

This is just a tip, used to avoid repeated submission of a form. This can prevent some phenomena of water, and sometimes users don't know if the user is successful due to network conditions, and will submit the same form again.

The main principle of this technique is not allowed to submit again after retreating, that is, the revision is not allowed after retreating, and it is not allowed, and the Irrigation method of Ctrl-C / Ctrl-V is not allowed. Is there any use, or a preference of the webmaster?

转载请注明原文地址:https://www.9cbs.com/read-112380.html

New Post(0)