ASP生成静态页之登陆及验证(7)
将以下代码保存为:login.asp
<!--#include file="conn.asp" -->
<!--#include file="md5.asp" -->
<%
if session("usre")<>"" then
response.redirect "adminnews.asp"
else
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理登陆</title>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
color: #000000;
margin:0px auto;
line-height:25px;
}
.table {
margin-top:80px;
border:1px #e6e6e6 solid;
}
.title {
line-height:30px;
text-align:right;
background:#FAFAFA;
}
.input {
font-size:14px;
border-top:#CDCDCD 1px solid;
border-left:#CDCDCD 1px solid;
border-right:#eeeeee 1px solid;
border-bottom:#eeeeee 1px solid;
height:18px;color:#333333;
vertical-align:middle;
padding:1px;
letter-spacing:0px;
background-color:#FAFAFA;
}
-->
</style>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
<form id="form1" name="form1" method="post" action="loginchk.asp">
<tr>
<td width="100" class="title">用户名:</td>
<td><input name="user" type="text" class="input" id="user" /></td>
</tr>
<tr>
<td class="title">密 码:</td>
<td><input name="pass" type="password" class="input" id="pass" /></td>
</tr>
<tr>
<td class="title">验证码:</td>
<td><input name="VerifyCode" type="text" class="input" id="VerifyCode" style="width:100px;"/> <img src="code.asp?" alt="图片看不清?点击重新得到验证码" width="60" height="20" align="absmiddle" style="cursor:hand;" onClick="this.src+=Math.random()" /></td>
</tr>
<tr>
<td class="title"> </td>
<td><input name="Submit" type="submit" value="登 录" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</form>
</table>
</body>
</html>
将以下代码保存为:loginchk.asp
<!--#include file="conn.asp" -->
<!--#include file="md5.asp" -->
<%
user=Replace(request.Form("user"), "'", "''")
pass=md5(Request("pass"))
VerifyCode=request.form("VerifyCode")
if user="" then
response.Write("<script language=javascript>alert('请填写用户名!');history.go(-1)</script>")
response.end
end if
if pass="" then
response.Write("<script language=javascript>alert('请填写密码!');history.go(-1)</script>")
response.end
end if
if VerifyCode="" then
response.Write("<script language=javascript>alert('请填写验证码!');history.go(-1)</script>")
response.end
end if
if cstr(Session("firstecode"))<>cstr(Request.Form("VerifyCode")) then
response.Write("<script language=javascript>alert('验证码不正确!');history.go(-1)</script>")
response.End
end if
sql="select * from Manage where user='"&user&"' and pass='"&pass&"'"
set rs=conn.execute(sql)
if rs.eof or rs.bof then
response.Write("<script language=javascript>alert('用户名或密码错误!');history.go(-1)</script>")
else
session("user")=rs("id")
session.timeout=60 '登陆会话时间,60分钟后自动退出。
%>
<%response.redirect "adminnews.asp"
end if
%>
最新评论
强大!
The purchases I make...
At last! Somonee who...
Good job mkanig it a...
How neat! Is it real...
Unparalleled accurac...
Thanky Thanky for al...
That's an inenguios ...
Holy szhinit, this i...
If you wrote an atri...