用asp如何写验证码?

每次刷新自动生成图片验证码,使用的时候判断不为空,和是否输入正确!要源代码,别来讲理论,谢谢,急求
在线等,会的麻烦了,没对的一直加分

下面是获得验证码的函数文件,保存文件为getcode.asp

<%
Option Explicit
Response.buffer=true
NumCode
Function NumCode()
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
dim zNum,i,j
dim Ados,Ados1
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("GetCode") = zNum
dim zimg(4),NStr
NStr=cstr(zNum)
For i=0 to 3
zimg(i)=cint(mid(NStr,i+1,1))
Next
dim Pos
set Ados=Server.CreateObject("Adodb.Stream")
Ados.Mode=3
Ados.Type=1
Ados.Open
set Ados1=Server.CreateObject("Adodb.Stream")
Ados1.Mode=3
Ados1.Type=1
Ados1.Open
Ados.LoadFromFile(Server.mappath("images/body.Fix"))
Ados1.write Ados.read(1280)
for i=0 to 3
Ados.Position=(9-zimg(i))*320
Ados1.Position=i*320
Ados1.write ados.read(320)
next
Ados.LoadFromFile(Server.mappath("images/head.fix"))
Pos=lenb(Ados.read())
Ados.Position=Pos
for i=0 to 9 step 1
for j=0 to 3
Ados1.Position=i*32+j*320
Ados.Position=Pos+30*j+i*120
Ados.write ados1.read(30)
next
next
Response.ContentType = "image/BMP"
Ados.Position=0
Response.BinaryWrite Ados.read()
Ados.Close:set Ados=nothing
Ados1.Close:set Ados1=nothing
End Function
%>
man.asp的代码如下:

<%if request("verifycode")="" then
response.Write "<script LANGUAGE=javascript>alert(请输入验证码!);history.go(-1);</script>"
response.end
end if

if cstr(session("getcode"))<>cstr(trim(request("verifycode"))) then
response.Write "<script LANGUAGE=javascript>alert('请输入正确的验证码!');</script>"
response.write "<meta http-equiv=refresh content=""1;URL=login.asp"">"
response.end
end if%>
其中login.asp种调用验证码的代码为:
<img src="getcode.asp" />
百度上榜你找的~不会的话 百度M我
温馨提示:答案为网友推荐,仅供参考
相似回答