回 帖 发 新 帖 刷新版面

主题:急!!!请教高手我的代码怎么不能实现不同用户登录不同界面呢?

<% @ language=VBScript %>
<html>
<head>
<title>
logincheck.asp 
</title>
</head>
<body>
<%
 Function CheckPwd(id,password,privilege)
    sql1 = "Select * From webusers Where username ='" & id & "'And password = '" & password & "'And privilege = '" & privilege & "'"
    sql2 = "Select * From webusers Where username ='" & id & "'And password = '" & password & "'And privilege = '系统管理员'"
    Set rs = conn.Execute(sql1)
    if rs.EOF then 
      Set rs = conn.Execute(sql2)
      if rs.EOF then
      CheckPwd = False
      else 
       CheckPwd =True
      end if
    Else
      sid= rs("id")
      spwd=rs("password")
      sprivilege= rs("privilege")
     ' susername=rs("username")
      CheckPwd =True
     End If 
 End Function
  
dim conn
dim connstr
on error resume next  
 Set conn=Server.CreateObject("ADODB.Connection")
 DBPath=Server.MapPath("webuserbook.mdb")
 connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath
 if err then 
err.clear
else
    conn.Open connstr
    if err then
    err.clear
    end if
 end if

 id = Request("id")
 password = Request("password") 
 privilege = Request("select")
 'Response.Write id
 'Response.Write password
 'Response.Write privilege
 
 Session("Passed")= False
 if id = "" Or password = "" Then
    Response.Redirect "ErrorPassword.htm"
    'response.Write("用户名和密码不能为空")
 Else
    if Not CheckPwd(id,password,privilege)Then
    'response.Write("用户名或密码错误!")
     Response.Redirect "ErrorPassword.htm"     
        Session("Passed")= False  'zxl
     Else
        Session("Passed")= True
     End If
  end if
  
 if Session("Passed")= True then  

    sCookieTime = CStr(Day(Date()) + Second(Time())) + CStr(Month(Date()) + Minute(Time()))
    sCookieKey = "8374364" + sCookieTime
    Session.Timeout = 10
    Session("DateTime") = sCookieTime
    Session("UserKey") = sCookieKey    

 select case privilege
    case "yd"
    Response.Redirect "./mainpage.asp"    
    
    case "on2000"
    Response.Redirect "./mainpageyd.asp"    
    
    case "sc"
    Response.Redirect "./mainpagesc.asp"    
    
    case "pt"    
    Response.Redirect "./mainpagept.asp"    
    
    case else
    Response.Redirect "./mainpagept.asp"    
 end select     
 end if
 %>
 </body>
 </html>
代码只能实现privilege=0n2000的界面  别的界面都进不去 privilege=sc或 pt就提示用户名或密码错误   错在哪里呢? [em10]

回复列表 (共1个回复)

沙发

试着把privilege输出来看看是什么???我只能看到程序的一部分,所以不好怎么说,你可以在select case privilege
前面写上一句:
response.write privilege
response.end()
当你选择不同的下拉列表项时看页面显示的值是否按您的意思显示,如果都相同肯定是你程序的问题。

我来回复

您尚未登录,请登录后再回复。点此登录或注册