login.asp
来自「ASP入门与提高实用教程 源文件(上传网站)」· ASP 代码 · 共 114 行
ASP
114 行
<!--#include file=../inc/conn.asp-->
<!--#include file=../inc/md5.asp -->
<!--#include file=../inc/const.asp -->
<% dim rs , exec %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>uuu</title>
<META name="Author" content="HappyNothing">
<link rel="stylesheet" href="style/1.css" type="text/css">
<style type="text/css">
<!--
.style1 {
font-family: "仿宋_GB2312";
font-size: 16pt;
color: #CCCCCC;
}
-->
</style>
</head>
<body>
<br>
<table width="400" border="1" align="center" cellpadding="10" cellspacing="0" bordercolor="#666666" bordercolorlight="#000000" bordercolordark="#FFFFFF" bgcolor="#999999" >
<tr>
<td align=center><span class="style1">用户登陆
</span></td>
</tr>
<tr>
<td align="center">
<%
main()
connclose()
sub main()
dim backInput
backInput= "<br><br><input type=button value=返回前页 onClick=history.back() class=button1 name=button ><br>"
if request.form="" then
%>
<form name="form" method="post">
<table width="80%" border="0">
<tr>
<td width="26%">用户名:</td>
<td colspan="2">
<input type="text" name="name" size="20" class="inputc" value="" maxlength="20">
</td>
</tr>
<tr>
<td>密 码:</td>
<td colspan="2">
<input type="password" name="pass" size="20" class="inputc" value="" maxlength="20" >
</td>
</tr>
<tr align="center">
<td height="40">
<br>
</td>
<td width="29%" height="40"><input type="submit" value="登陆" class="button1" name="Submit" ></td>
<td width="45%" align="left"><input name="Submit2" type="reset" class="button1" value="重置"></td>
</tr>
</table>
</form>
<%
else
dim name, pass,power
name=Encodestr(request.form("name"))
pass=Encodestr(request.form("pass"))
if name="" or pass="" then
response.write "<font color=red>发生错误</font><br><br>请输入用户名和密码!!!"
response.write backInput
exit sub
end if
pass=MD5(pass)
exec="select * from users where username='"&name&"' "
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3
if rs.eof then
rsclose()
response.write "<font color=red>发生错误</font><br><br>用户名不存在!!!"
response.write backInput
exit sub
elseif (StrComp(name,trim(rs("username")),0) <>0 or StrComp(pass,trim(rs("password")),0)<>0) then
rsclose()
response.write "<font color=red>发生错误</font><br><br>密码错误!!!"
response.write backInput
exit sub
end if
session("admin")=name
session("password")=pass
rs("logins")=rs("logins")+1
rs("lasttime")=now()
rs("lastip")=request.servervariables("remote_addr")
rs.update
rsclose()
response.write "<font color=red>登陆成功!!!</font>"
response.Redirect("index.asp")
end if
end sub %>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?