Author: Loster (OICQ: 181306) If reproduced, please do not remove this line, thank you.
Now that many websites have a verification code, the verification code is generally displayed in the form of a picture. In this way, it is possible to improve the security of landing and prevent violence. Why use the picture to display the verification code? Imagine that if only the verification code of the text is generated, the crack person can use the technology similar to the thief, first read your page, then analyze the verification code, and finally the violent guess. In this case, there is no practical meaning of the verification code. Noteping less, I will start to say how to display the picture verification code in the ASP.
To implement the image verification code in the ASP, you first need three files:
Getcode.asp (used to generate image verification code)
Head.fix (picture head)
Body.fix (picture main body)
You may ask, where can I get these files? No need to worry, these documents are in DVBBS7.0. I also learned how to use the picture verification code after studying the verification code in DVBBS7.0.
First look at the getCode.asp file, there are several lines in this:
ADOS.LOADFROMFILE (Server.Mappath)) ADOS1.WRITE ADOS.READ (1280) for i = 0 to 3 ads.position = (9-zimg (i)) * 320 ADOS1.Position = i * 320 ADOS1.WRITE ADOS.READ (320) Next Ados.LoadFromfile (Server.MAppath ("Head.fix"))
Have you seen Body.fix and Head.fix? Here is the relative position of them with getCode.asp. If they do three files in a directory, they can follow the above writing. If not, you need to write the relative positions of both of them with getcode.asp. For example, if getCode.asp is in the root directory, Body.fix & Head.fix is under the TEST folder under the root directory, then the above code needs to be changed:
AdoS.LoadFromfile (Server.Mappath ("Test / Body.fix")) ADOS1.WRITE ADOS.READ (1280) for i = 0 to 3 ads.position = (9-zimg (i)) * 320 ADOS1.POSITION = i * 320 adoS1.write ads.read (320) Next Ados.LoadFromfile (Server.MAppath ("Test / Head.fix"))
This will ensure that the picture is displayed normally.
How to call?
Very simple, just like this:
I.e.
Whenever you call getCode.asp, a session is automatically generated, which stores and verify the same four digits displayed on the picture. You just need to compare the received verification code and this session, then determine if the verification code is correct. Of course, it is best like this:
IF CSTR (TRIM (received variable name) = cstr (session ("getcode") thein
Response.write ("OK!")
Else
Response.write ("NO!")
END IF
Oh, it's time, it's over. I hope that you will be inspired after reading this article. Of course, the level is limited, and there is a mistake in the article. You are welcome to correct. Some people may ask, the picture can be modified, the answer is yes, there is a related article online, you can go.
Attached: http://www.loster.net/aspfile/getcode.rar getcode.asp, head.fix, body.fix file compression package