| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 329 人关注过本帖
标题:用户登录失败后不能返回登录页面 [已解决,谢谢您的关注!]
只看楼主 加入收藏
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
结帖率:87.5%
收藏
 问题点数:0 回复次数:1 
用户登录失败后不能返回登录页面 [已解决,谢谢您的关注!]

登录成功后,能成功返回首页(index.asp)
可登录失败后,却不能返回此登录页面(yhdl.asp),仍停留在登录执行页面(yhdlzx.asp)(空白)
请各位老师在下面的代码中帮学生改一改吧!多谢!


登录页面:yhdl.asp

<table width="800" height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><form action="yhdlzx.asp" method="post" name="form1" target="_blank" id="form1">用户名:
          <input name="name" type="text" id="name" size="15">
       &nbsp;密码:
       <input name="pwd" type="password" id="pwd" size="15">
   &nbsp;&nbsp;
   <input type="submit" name="Submit" value="登     录">
    &nbsp;&nbsp;&nbsp;&nbsp; 注&nbsp; 册
    </form></table>
登录执行页面:yhdlzx.asp
<!--#include file="../conn.asp" -->
<%
Session("name")=request.form("name")'在 Session中保存用户名
dim username,password
name=request.form("name")'从表单传递的用户名
pwd=request.form("pwd")
'查询记录
set rs=server.CreateObject("adodb.recordset")
sql="select * from yhgl where name='"&name&"'"
rs.open sql,conn,1,1
if rs.eof then
response.write "<script>alert('登录失败,用户名不对');history.back();</script>"
response.end
else
Session("MM_Username") = MM_valUsername
if rs("pwd")<>pwd then
response.write "<script>alert('登录失败,密码不对');history.back();</script>"
response.end
end if
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("name"))
If MM_valUsername <> "" Then
  MM_fldUserAuthorization="yhjb"
  MM_redirectLoginSuccess="../index.asp"....登录成功后,能成功返回首页
  MM_redirectLoginFailed="yhdl.asp".........可登录失败后,却不能返回此登录页面,仍停留在登录执行页面(yhdlzx.asp)
  MM_flag="ADODB.Recordset"
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = conn
  MM_rsUser.Source = "SELECT name, pwd"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM yhgl WHERE name='" & Replace(MM_valUsername,"'","''") &"' AND pwd='" & Replace(Request.Form("pwd"),"'","''") & "'"
  MM_rsUser.CursorType = 0
  MM_rsUser.CursorLocation = 2
  MM_rsUser.LockType = 3
  MM_rsUser.Open
  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    Session.Timeout = 120
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccess)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
session("admin")=username
End If
End If
conn.close            '关闭连接,
set conn=nothing      '释放内存 这两句很重要,不然会占用大量服务器资源
%>




[ 本帖最后由 tepnidh 于 2012-2-3 11:25 编辑 ]
2012-02-02 21:52
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
谢谢您啦!
2012-02-03 08:42
快速回复:用户登录失败后不能返回登录页面 [已解决,谢谢您的关注!]
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011852 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved