以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  移动端开发,居然只有李孝春这个账户可以登录进去,其它的都提示账户名或密码错误,拒绝登录了,求解  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=132570)

--  作者:李孝春
--  发布时间:2019/3/25 11:26:00
--  移动端开发,居然只有李孝春这个账户可以登录进去,其它的都提示账户名或密码错误,拒绝登录了,求解
移动端开发,居然只有李孝春这个账户可以登录进去,其它的都提示账户名或密码错误,拒绝登录了
systemuser表结构如下:

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20190325112403.png
图片点击可在新窗口打开查看
代码如下:
Dim wb As New weui
\'身份验证
Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If

If UserName <>"" AndAlso Password <>"" Then
    Dim dr11 As DataRow
    dr11 = DataTables("systemuser").Find("username = username")
    If UserName = dr11("username") AndAlso Password = dr11("Password") Then
        Verified  = True
    End If
End If


If Verified AndAlso e.Path = "logon.htm"  Then \'如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) \'将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页
    e.WriteString(wb.Build) \'生成网页
    Return \'必须的
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then \'如果用户身份验证失败,且访问的不是登录页面
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
    e.WriteString(wb.Build) \'生成网页
    Return \'必须的
End If

Dim fl As String = "d:\\web\\" & e.path
If filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String  = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'这里必须返回
    End Select
End If

Select Case e.Path
    Case "logon.htm" \'登录页面
        
        wb.AddPageTitle("","pageheader","信息推送系统","")
        If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then \'判断是否是验证失败后的重新登录
            wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示.
        End If
        wb.AddForm("","form1","logon.htm")
        With wb.AddInputGroup("form1","ipg1")
            .AddInput("username","户名","text")
            .AddInput("password","密码","password")
        End With
        With wb.AddButtonGroup("form1","btg1",True)
            .Add("btn1", "登录", "submit")
        End With
        
        e.WriteString(wb.Build)
        
    Case "exit.htm" \'退出登录
        wb.DeleteCookie("username") \'清除cookie中原来的用户名和密码
        wb.DeleteCookie("password")
        wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
        
    Case "", "default.htm" \'首页
        wb.AddPageTitle("","pageheader","信息推送系统","")
        With wb.AddGrid("","g1")
            .Add("c1","增加干警信息", "./images/button.png", "addnewtxl.htm")
            .Add("c2","信息推送编辑", "./images/cell.png", "")
            .Add("c3","查询干警信息", "./images/toast.png", "filter.htm")
            .Add("c4","增加案件关联人", "./images/dialog.png", "Addglr.htm") \'.Attribute = ""
            .Add("c5","新增批捕案件", "./images/progress.png", "Addpbaj.htm")
            .Add("c6","新增公诉案件", "./images/msg.png", "Addgsaj.htm")
            .Add("c12","退出", "./images/exit.png", "exit.htm") \'退出登录
        End With
End select

--  作者:有点甜
--  发布时间:2019/3/25 13:56:00
--  

dr11 = DataTables("systemuser").Find("username = username")

 

改成

 

dr11 = DataTables("systemuser").Find("username = \'" & username & "\'")