|
相关代码:
<tr>
<td align="right">验证码:</td>
<td><input name="code" size="4"><%call getcode()%></td>
</tr>
提交验证部分:
<%
if instr(request("login_name"),"'")<>0 then
response.write "<script language=JavaScript>" & chr(13) & "alert('非法数据提交!');" & "history.back()" & "</script>"
Response.End
else
call CodeIsTrue("member.asp")
password1=md5(request("password1"))
if request("user")="1" then
exec="select id,login_name,password1 from register where login_name='"&request("login_name")&"'"
end if
if request("user")="2" then
exec="select id,login_name,password1,vip from regvip where login_name='"&request("login_name")&"'"
end if
rs.open exec,conn,1,1
if rs.eof and rs.bof then
response.write "<script language=JavaScript>" & chr(13) & "alert('用户名错误!');" & "history.back()" & "</script>"
rs.close
set rs=nothing
set conn=nothing
response.end
else
if password1<>rs("password1") then
response.write "<script language=JavaScript>" & chr(13) & "alert('密码错误!');" & "history.back()" & "</script>"
rs.close
set rs=nothing
set conn=nothing
response.end
else
if rs("login_name")<>"" then session("login_name")=rs("login_name")
session("vip")=false
session("id")=rs("id")
session("login_name")=rs("login_name")
session("user")=request("user")
rs.close
set rs=nothing
set conn=nothing
response.redirect "login.asp"
end if
end if
rs.close
set rs=nothing
set conn=nothing
end if
%>
<%
'以下为常用过程
public sub GetCode()
response.write "<img src=""getcode.asp"" alt= ""验证码,看不清楚?请点击刷新验证码"" style=""cursor : pointer;height : 20px;"" onclick=""this.src='getcode.asp'""/> "
end sub
public sub CodeIsTrue(b)
if CStr(Session("GetCode"))<>cstr(Trim(Request("Code"))) then
randomize
Session("GetCode")=rnd()
if b="" then
response.write "<script language=JavaScript>" & chr(13) & "alert('验证码错误,请刷新页面后重新输入!');" & "history.back()" & "</script>"
else
response.write "<script language=JavaScript>" & chr(13) & "alert('验证码错误,请确认重新输入!');"&"window.location.href = '"&b&"'"&" </script>" '验证码对的 也运行到这边
end if
Response.End
end if
end sub
%> |
|