ASP implementation with refresh function verification code code _ Application Skills

Source: Internet
Author: User

Place the following code in a separate page checkcode.asp

<% Option Explicit response.buffer=true call Com_creatvalidcode ("Validatecode") Sub Com_creatvalidcode (PSN) ' Prohibit caching R Esponse.
Expires = -9999 Response.AddHeader "Pragma", "No-cache" Response.AddHeader "Cache-ctrol", "No-cache" Response.ContentType = "Image/bmp" Randomize Dim I, II, iii const CODDS = 2 ' clutter occurrence probability Const camount = 10 ' Text quantity Cons T ccode = "0123456789" ' Color data (character, background) Dim Vcolordata (1) vcolordata (0) = ChrB (0) & ChrB (0) & ChrB (211) ' Blue 0, Green 0, Red 0  (black) vcolordata (1) = ChrB (255) & ChrB (255) & ChrB (255) ' Blue 250, green 236, red 211 (light blue) ' randomly produces characters Dim vcode (4), Vcodes for I = 0 to 3 vcode (i) = Int (Rnd * camount) vcodes = vcodes & Mid (Ccode, Vcode (i) + 1, 1) Next session (PSN) = Vcodes ' record into S Ession ' character data Dim Vnumberdata (9) vnumberdata (0) = "
1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111 110000111 "
 
Vnumberdata (1) = "1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111 100000111 "
Vnumberdata (2) = "1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111 100000011 "Vnumberdata (3) ="
1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111 110000111 "
 
Vnumberdata (4) = "1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111 111000011 "Vnumberdata (5) ="
1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111 110000111 "
 
Vnumberdata (6) = "1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111 110000111 "Vnumberdata (7) ="
1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111 111011111 "
 
Vnumberdata (8) = "1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111 110000111 "Vnumberdata (9) =" 1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111 110001111 "
' Output image file header Response.BinaryWrite ChrB (& ChrB () & ChrB (230) & ChrB (4) & ChrB (0) & ChrB (0) & Ch  RB (0) & ChrB (0) &_ ChrB (0) & ChrB (0) & ChrB (i) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (40) & ChrB (0) &_ ChrB (0) & ChrB (0) & ChrB (+) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (a) & ChrB (0) &_ ChrB (0) & ChrB (0) & ChrB (1) & ChrB (0) ' Output image information header Response.BinaryWrite ChrB () & ChrB (0) & Amp ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (176) & ChrB (4) &_ ChrB (0) & ChrB (0) & ChrB ( & ChrB (one) & ChrB (0) & ChrB (0) & ChrB (a) & ChrB (one) &_ ChrB (0) & ChrB (0) & ChrB (0) &A mp ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_ ChrB (0) & ChrB (0) For i = 9 to 0 Step-1 ' after All lines for II = 0 to 3 ' after all the words for III = 1 to 10 ' through all pixels ' line-by-row, verbatim, pixel output image data If Rnd * + 1 < Codds Then ' randomly generated miscellaneous points respons E.binarywrite VColordata (0) Else response.binarywrite vcolordata (Mid (Vnumberdata (Vcode (ii)), I * + III, 1)) End If Next Next
 Sub%>

Pages that need to be used are referenced in the following ways:

Verification code: src= "checkcode.asp" alt= "verification code, can not see clearly?" Please click Refresh Verification Code "height=" "style=" cursor:
Pointer "onclick=" this.src= ' checkcode.asp?t= ' + (new Date (). GetTime ()); ">

Judgment page:

<%
If Trim (Session ("Validatecode")) <> Trim (Request ("Txt_check")) then
errormessage = "Please enter the correct authentication code"
Response.Write ("<script>alert" (' &ErrorMessage& '); location.href= ' Default.asp ' </script > ")
response.end end
if
%>

The above mentioned is the entire content of this article, I hope you can enjoy.

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.