这个问题我知道啊
大概需要4 5 个文件, 代码很多, 实游辩例在我给的连接里可以下载, 这样基本能解决了 LZ给分吧
其中一共用到5个文件(以登录为例).验证页面login.asp,产生验证码的页面getcode.asp,登陆页面的提交页面main.asp和两个数字
图像文件--body.fix和head.fix
其中getcode.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=""1URL=login.asp"">"
response.end
end if%>
其中login.asp种调用验证码的代码为:
<img src="getcode.asp" />
改成这样<%@ Language=VBScript %>
<!--#INCLUDE FILE="conn.asp" -->
<%
name=trim(request.form("name"))
password=trim(request.form("肢蚂漏password"))
set rs=server.createobject("adodb.recordset")
sql="select * from photouser where id=1"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if password<>rs("pwd") or name<>rs("user") then
response.write "<script language='javascript'>"
response.write "alert('你的输入的姓名和生日其中有一项是历烂错误的~~~')"
response.write "history.go(-1)"
response.write "</script>"
response.end
else
session("name")="named"
session("password")="passed"
response.redirect"物槐photos.asp"
end if
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)