代码如下: <!--#include file="common.asp"--> <!--#include file="top.asp"--> <% session.Abandon select case request("act") case "admchk" call admchk() case "logout" call logout() case else call login() end select
sub login() %> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- body { font-family: Verdana, Arial, "宋体", Tahoma; color: #003366; background-color: #FFFFFF; } .table1 { border: 1px #555555;background-color: #555555; } A:link,A:active,A:visited { color: #003366; text-decoration: none; } a:hover { color: #000000; text-decoration: underline; } .style2 {font-size: 9pt} --> </style> </head>
<body> <form action="?act=admchk" method="POST"> <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse " bordercolor="#666666" width="100%" height="70%"> <tr> <td width="43%" height="80" valign="bottom"><img src="/images/admin.gif" width="30" height="27" border="0" align="right"></td> <td width="57%" height="80" valign="bottom"> <p align="left" class="style2"><b>管理登陆</b></td> </tr> <tr> <td width="100%" height="234" colspan="2" align="center" valign="top"> <div align="center"> <center> <table border="0" cellpadding="3" cellspacing="1" class="table1" width="70%"> <tr> <td width="40%" height="17" bgcolor="#FFF3C4" class="tablebody3"> <p align="right"><span class="style2">用户名称</span>:</td> <td width="60%" height="17" bgcolor="#E1E9F0" class="tablebody2"><input type="text" name="name" size="20"></td> </tr> <tr> <td width="40%" height="35" bgcolor="#FFF3C4" class="tablebody3"> <p align="right"><span class="style2">用户密码</span>:</td> <td width="60%" height="35" bgcolor="#E1E9F0" class="tablebody2"><input type="password" name="password" size="20"></td> </tr> <tr> <td width="40%" height="35" align="right" bgcolor="#FFFFFF" class="style2">注意:大小写敏感</td> <td width="60%" height="35" bgcolor="#FFFFFF" class="tablebody1"><input type="submit" value="提交" name="B1"> <input type="reset" value="重置" name="B2"></td> </tr> </table> </center> </div> </td> </tr> </table> </form> <% end sub
sub admchk()
dim username,password username=trim(request("name")) password=trim(request("password"))
sql="Select username,password,level1 From [user] where username='"&username&"'" set rs=server.CreateObject("adodb.recordset") rs.open sql,conn,1,3 if rs.eof then errinfo="名称或密码错误,请注意大小写。" error(errinfo) rs.close set rs=nothing conn.close set conn=nothing response.End end if if not (rs("password")=password) then errinfo="名称或密码错误,请注意大小写。" error(errinfo) rs.close set rs=nothing conn.close set conn=nothing response.End end if session("username")= rs("username") session("userlevel")=rs("level1")
if session("userlevel")=1 then response.Redirect"admin.htm" elseif session("userlevel")=2 then response.Redirect"teacher.htm" elseif session("userlevel")=3 then response.Redirect"student.asp" end if
rs.close set rs=nothing end sub %> <!--#include file="foot.asp"--> </body> </html>
实在不知道是iis或asp的问题,标题不太明确,抱歉
运行以上代码,用帐号登陆后,有时候可以进去,有时候又不行,此时页面显示 由于网页地址不正确,正在查找的网页无法显示。 HTTP 错误 405 - 禁止访问资源 好心人们帮帮忙啊
[此贴子已经被作者于2004-09-11 12:19:23编辑过]