[求助]帮我看看我的验证码,为什么用不了好吗?
以下是表单页面user.asp<form action="user_login.asp" method="post" name="login" id="login">
<tr>
<td height="20" align="right" class="title">用户名:</td>
<td height="20" align="left"><input name="username" type="text" id="username" size="12" maxlength="50" /></td>
</tr>
<tr>
<td height="10" align="right" class="title">密码:</td>
<td height="10" align="left"><input name="userpow" type="text" id="userpow" size="12" maxlength="50" /></td>
</tr>
<tr>
<td height="10" colspan="2" align="right" class="title">验证码:<input type="text" size="9" maxlength=="6" name="code"><img src="code.asp" align="absmiddle" onclick="this.src='code.asp?rndcode=' + Math.random();" style="cursor:pointer;" alt="看不清请点击更换!"> </td>
</tr>
<tr>
<td height="20" colspan="2" align="center" valign="middle" class="title"><label>
<input type="submit" name="button" id="button" value="提交">
</label>
<a href="user_apply.asp">注册</a></td>
</tr>
</form>
以下是验证码页面code.asp
<%
Option Explicit
Response.buffer = True
NumCode (1)
Function NumCode(CodeType)
Response.Expires = -1
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-ctrol", "no-cache"
On Error Resume Next
Dim zNum, rNum, i, j, listnum, listcode
Dim Ados, Ados1
listcode = "0123456789abcdefghijklmnopqrstuvwxyz"
Randomize Timer
Dim zimg(6), NStr
For i = 0 To 5
rNum = CStr(CInt(35 * Rnd)) '将35改为9即为使用纯数字密码
zimg(i) = rNum
listnum = listnum & Mid(listcode, rNum + 1, 1)
Next
Session("ChkCode") = listnum
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" & CodeType & ".Fix"))
Ados1.write Ados.read(2880)
For i = 0 To 5
Ados.Position = (35 - zimg(i)) * 480
Ados1.Position = i * 480
Ados1.write Ados.read(480)
Next
Ados.LoadFromFile (Server.mappath("head.fix"))
Pos = LenB(Ados.read())
Ados.Position = Pos
For i = 0 To 15 Step 1
For j = 0 To 5
Ados1.Position = i * 32 + j * 480
Ados.Position = Pos + 30 * j + i * 270
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") = "999999"
End Function
%>
body1.fix和Head.Fix文件我都有了。
以下是表单确认页面user_login.asp
<%
dim conn
set conn = Server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("../data/data.mdb")
%>
<%
if Request("username")<>"" then
sql="select * from userhao where username='" & trim(request("username")) & "' and userpow='" & replace(trim(request("userpow")),"'","''") & "'"
'response.write sql
'response.End
set rs = conn.Execute(sql)
if not (rs.eof or err) then
session("username")=rs("username")
session("userpow")=rs("userpow")
session("uuserfirm")=rs("uuserfirm")
session("useradd")=rs("useradd")
session("usertel")=rs("usertel")
session("userfax")=rs("userfax")
session("email")=rs("email")
session("oicq")=rs("oicq")
session("userreason")=rs("userreason")
session("tong")=rs("tong")
a=rs("tong")
response.redirect "index.asp"
else
%>
<script language=Javascript>
alert("错误!请重新输入");
window.history.go(-1);
</script>
<%end if%>
<%end if%>