[Asp] how to add a verification code

Source: Internet
Author: User

There are many people who need it, and many people have asked, I remember a detailed reply in a post.
Now, sort it out!
1. Download an object
Imgchk.rar
The compressed package is an imgchk folder, which has three files: validatecode. asp, validatebody. fix, validatehead. fix
This service is mainly used to generate verification codes.

Release the decompressed folder directly to the same directory where you need to add verification codes on a page.
(For example, you need to add a verification code to addnew. asp. If the file is in the cnbruce folder, The imgchk folder will be released to the cnbruce folder at the same time)

2. Add the verification code and input box

Add the following code to the page where you want to add a verification code:

<Input name = 'validatecode' type = 'text' size = '5'>
3. Record acceptance page processing

In step 2, the record will be submitted to a page for processing, 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 that the verification code is entered correctly ")
Response. end
End if
Code copy box
If Trim (Request. Form ("validatecode") = Empty Or Trim (Session ("cnbruce.com _ ValidateCode") <> Trim (Request. Form ("validatecode") Then
Response. write ("Please note that the verification code is entered correctly ")
Response. end
End if
[Ctrl + A select all and copy]

Verification Code principle:
When a verification code image is generated, a Session is generated at the same time. The value is the numerical value in the verification code image.

In addition, the input box is provided for the user to input. After the input value is submitted, it is compared with the existing Session value and determined based on the judgment result.

If you need to modify the Session name, there are only two changes:

A: The validatecode. asp file in the imgchk folder you downloaded involves modifying cnbruce.com to yours;

B: Switch cnbruce.com in Trim (Session ("cnbruce.com _ ValidateCode") <> Trim (Request. Form ("validatecode") in step 3 to the one set by.

In addition ==================================
Patch for displaying Verification Code (some friends do not display the verification code. Let's take a look)

Use the following content to create the file SP2.reg (you can use NotePad to save the file by selecting "Save ")

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Internet Explorer \ Security]
"BlockXBM" = dword: 00000000

Double-click to import the registry, and restart the machine.

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.