Php prevents repeated form submission, php prevents form submission _ PHP Tutorial

Source: Internet
Author: User
Php prevents repeated forms and php prevents form submission. Php prevents repeated submission of forms. php prevents users from submitting forms due to the speed of the network or malicious refreshing of webpages, this causes the same record to be inserted to the database repeatedly. php prevents repeated submission of forms, and php prevents form submission.

When a user submits a form, the same record may be repeatedly inserted into the database due to the speed of the network or the malicious refreshing of the webpage. this is a tricky problem. We can start with the client and the server to avoid repeated submission of the same form.

1. use client scripts

[Php]View plaincopy


After you click the submit button, the button becomes unavailable.
In the above example, the OnClick event is used to detect the user's submission status. if you click the submit button, the button is immediately set to invalid. you cannot click the button to submit again.

Another method is to use JavaScript, but the OnSubmit () method is used. if a form has been submitted once, the dialog box is displayed immediately. the code is as follows:

[Php]View plaincopy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.