Example of php preventing remote form submission outside the site

Source: Internet
Author: User
Preventing webmasters from submitting a form is nothing more than adding a token to each open form or submit data for verification. this is actually no different from the verification code, the following are several examples of preventing remote form submission outside the site. example 1: Every time we open the submit page, we generate... preventing webmasters from submitting a form is nothing more than adding a token to each open form or submit data for verification. this is actually no different from the verification code, the following are several examples of preventing remote form submission outside the site.

Example 1: Each time we open the submit page, a token is generated and saved in the session. when the form is submitted, we can determine whether the current token value is consistent with the session value, if yes, the request is submitted normally. Otherwise, the request is submitted invalid.

The PHP instance code is as follows:

 

Another obvious method is to use the verification code, which is the same as other methods. let's look at a simple example below.

Add verification code:The verification code is added when the form is submitted, which can effectively prevent the filling machine from submitting data. However, as the graphic image recognition program becomes more powerful, the verification code recognition is constantly improving its difficulty, some verification codes even include voice recognition. some small sites can adopt this method. the code is as follows:

If ($ _ POST ['vcode']! = Get_vcode ())

{

Exit ('verification code verification failed, unable to warehouse receiving ');

}

For specific examples, we will not introduce many online verification examples.

Address:

Reprinted at will, but please attach the article address :-)

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.