ASP code to add verification code to the Web page implementation method

Source: Internet
Author: User
Tags numeric value trim

This article introduces the ASP implementation to the webpage to add the authentication code function, you may add this function in the registration form, the webpage comment and so on, the below view realizes the method:

First step: Download the attachment under this article. The compressed package is a Imgchk folder with three files: Validatecode.asp,validatebody.fixvalidatehead.fix

The main is to generate the authentication Code service.

Release the unzipped folder directly in the same directory where you need to add a captcha to a page (for example, addnew.asp needs to add a CAPTCHA, which is under the Cnbruce folder, the Imgchk folder is released to the Cnbruce folder at the same time)

Step Two: Add display verification code and input box

Add the following code to the page where you want to add the authentication code:

Step three: Record accept page processing

In step 2, you must submit the records to a page, and then add the following code to the processing page:

If Trim (Request.Form ("Validatecode")) =empty Or Trim (Session ("Cnbruce.com_validatecode")) <>trim (Request.Form ("Validatecode")) Then

Response.Write ("Please note the correct input of the verification Code")

Response.End

End If

Verification Code principle:

When you generate a CAPTCHA picture, a session is generated with the value of the numeric value in the Captcha picture.

At the same time, provide input box for user input, submit input value, compared with the existing session value, according to the judgment result make corresponding judgment.

If you need to modify the name of the session, only two places are changed:

A: You download the Imgchk folder in the validatecode.asp, which involves the cnbruce.com to your;

B: Just step 3 of the Trim (session ("Cnbruce.com_validatecode")) <>trim (Request.Form ("Validatecode")) The cnbruce.com in is changed to a set.

In addition ===================================================

Show the check code patch (some friends show no verification code, here to see)

Create a file Sp2.reg with the following content (Notepad, save As)

Windows Registry Editor Version 5.00

[Hkey_local_machinesoftwaremicrosoftinternet explorersecurity]

"BLOCKXBM" =dword:00000000

Double-click the Import registry, and then restart the machine.

All right, so far, the verification code has been added, you can try to register several account number of the experiment, the only bad thing is that if you do not enter the verification code point to determine the words will automatically go to another page, the font is good ugly, there are free kung fu people can be changed to pop-up prompts,

Response.Write ("")

Related Article

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.