[开源]图片验证码技术
这些代码实现在了 图片片验证为空的,怎么实现判断验证码是否正确???<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
<script language="javascript" >
function CheckForm(form){
if(form.checkcode.value==""){
alert("错误提示:\n\n请你填写验证码 ");
return false;
谁能这里写一些代码来实现判断验证码是否正确
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="" onSubmit="return CheckForm(this)">
<span class="style1">输入验证码</span>:
<input name="checkcode" type="text" size="6">
<span class="style1">验证码:</span><img src="code.asp">
<input type="submit" name="Submit" value="提交" >
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
code.asp代码
code.asp
<%
Option Explicit
Response.buffer=true
NumCode
Function NumCode()
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
On Error Resume Next
Dim zNum,i,j
Dim Ados,Ados1
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("CheckCode") = 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("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("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
If Err Then Session("CheckCode") = 9999
End Function
%>