SoFunction
Updated on 2025-03-02

[asp] Solution to how to add verification code

There are many people who need it, and many people ask, and I remember making a detailed reply in a post.
Now sort it out!
1. Download the file
  
The compressed package is the imgchk folder, which has three files:,
It mainly serves to generate verification codes.

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

2. Add display verification code and input box

Add the following code to the page where verification code needs to be added:

<input name='validatecode' type='text' size='5'>&nbsp;<img src='imgchk/' align='absmiddle' border='0'>
3. Record acceptance page processing

In step 2, the record will be submitted to a page for processing, so add the following code to the processing page:

If Trim(("validatecode"))=Empty Or Trim(Session("cnbruce.com_ValidateCode"))<>Trim(("validatecode")) Then
("Please note that the verification code is entered correctly")

end if
Code copy box
If Trim(("validatecode"))=Empty Or Trim(Session("cnbruce.com_ValidateCode"))<>Trim(("validatecode")) Then
("Please note that the verification code is entered correctly")

end if
[Ctrl+A Select all and copy]

Verification code principle:
When generating the verification code picture, a session is generated at the same time, and its value is the numeric value in the verification code picture.

At the same time, an input box is provided for the user to enter. After submitting the input value, it is compared with the existing Session value and makes corresponding judgments based on the judgment results.

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

a: Change the imgchk folder you downloaded to yours;

b: It is to replace the Trim(Session("cnbruce.com_ValidateCode"))<>Trim(("validatecode"))) in Step 3 just now with the set of a.

In addition=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
Patch that displays the verification code (some friends cannot display the verification code, please take a look here)

Create a file with the following content (it's OK with Notepad, select "Save As" when saving)

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