login.asp

来自「86bed md5 密码转换与查询工具(带数据库)」· ASP 代码 · 共 132 行

ASP
132
字号
<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<%
dim action
action = request.querystring("action")
call head()
if action="login" then
	call login()
elseif action="logout" then
	call logout()
else
	if session("administrator")<>"" then
		response.redirect "edit.asp"
	end if
	call logface()
end If
call foot()

sub login()
	fname=request.form("name")
	pass=MD5(request.form("pass"))
	if fname<>"" then
	sql="select * from admin where admin='"&fname&"'"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	if not rs.eof then
		if ucase(pass)=ucase(rs("pws")) then
		   Response.Cookies("admin")="guoxue"
                 session("administrator")="administrator"
                  session("id")=rs("id")
			response.redirect "edit.asp"
		Else
			Response.Write "<script>"
			Response.Write "alert('密码输入错误,请重新输入正确的密码。');"
			Response.Write "location.href='login.asp';"
			Response.Write "</script>"
		end if
	Else
		Response.Write "<script>"
		Response.Write "alert('没有此用户存在,请输入正确的用户名。');"
		Response.Write "location.href='login.asp';"
		Response.Write "</script>"
	end if
	end if
end sub

sub head()
%>
<html>
<head>
<style type="text/css">
<!-- 
td           { font-size: 12px; line-height: 17px }
body         { font-size: 12px; line-height: 17px }
p            { margin-top: 1; margin-bottom: 1 }
a:link       { text-decoration: none; color: black }
a:visited    { text-decoration: none; color: black }
a:active     { text-decoration: none }
a:hover      { text-decoration: underline; color: red }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>管理员登录</title>
<script language="javascript">

function checkform() {
 if(document.form1.name.value=="")
  {
  alert("请输入用户名!");
  document.form1.name.focus();
  return false;
  }
 if(document.form1.pass.value=="")
 {
 alert("密码不能为空,请输入密码!");
 document.form1.pass.focus();
 return false;
 }
}

</script>
</head>
<%
end sub
sub logface()
%>
<body background="images/bg.gif">
<br><br>
<form action="?action=login" name='form1' method="post" onsubmit="return checkform()">
<table align='center' border="0" width="200" cellspacing="0" cellpadding='5'>
	<tr><td colspan='2' align='center'><font size='3'> 系 统 管 理 </font><hr></td></tr>
   <tr>
      <td width="30%">
        <p align="right">帐号:</td>
          <td width="70%"><input type="text" name="name" size="15"></td>
            </tr>
            <tr>
           <td>
          <p align="right">密码:</td>
          <td><input type="password" name="pass" size="15"></td>
          </tr>
       <tr>
    <td colspan="2">
      <p align="center"><input type="submit" value="进 入" name="enter">&nbsp;&nbsp;   
      <input type="button" value="取 消" onclick="location.href='/'"></p>             
    </td>             
  </tr>  
  </table>  
  </form>  
<%
end sub
sub foot()
%>
</body> 
</html>            
<%
end sub

sub logout()
	session("administrator")=""
	Response.Cookies("admin")=""
         session("id")=""
	Session.abandon
	Response.Write "<script>"
	Response.Write "alert('你已经安全退出了系统。');"
	Response.Write "location.href='../index.asp';"
	Response.Write "</script>"
end sub
%>           

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?