以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  手机端验证登陆的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=107045)

--  作者:rjh4078
--  发布时间:2017/9/20 16:05:00
--  手机端验证登陆的问题
Dim zh As String = e.Cookies("zh") \'从cookie中获取用户名
Dim bh As String = e.Cookies("bh")
Dim mm As String = e.Cookies("mm") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("bh") AndAlso e.PostValues.ContainsKey("mm")  Then
        bh = e.PostValues("bh")
        mm = e.PostValues("mm")
’Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"e5","ff") & "\'" )
‘’If tr IsNot Nothing Then
 ‘’   Verified  = True
  ‘’  zh=tr("姓名")
‘’End If

    End If
End If
Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"e5","ff") & "\'" )
If tr IsNot Nothing Then
    Verified  = True
    zh=tr("姓名")
End If

放到蓝色部分
提示:
.NET Framework 版本:2.0.50727.8794
Foxtable 版本:2017.8.19.1
错误所在事件:项目,HttpRequest
详细错误信息:
String 引用没有设置为 String 的实例。
参数名: s
用messbox弹了一下bh mm是空值
我把身份验证判断放到红色部分 无法验证跳转 但bh mm有数据


--  作者:有点甜
--  发布时间:2017/9/20 16:17:00
--  

弹出,看看数据是什么

 

msgbox("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"e5","ff") & "\'")

 

在你的sql数据库那里执行sql语句查找数据

 

Select * from 人员表 where 条件


--  作者:rjh4078
--  发布时间:2017/9/20 16:59:00
--  
现在的问题是 我把验证代码放到红色部分,能够验证 但是不能跳转default.htm 一直在登录页来回循环
--  作者:rjh4078
--  发布时间:2017/9/20 17:04:00
--  
Dim zh As String = e.Cookies("zh") \'从cookie中获取用户名
Dim bh As String = e.Cookies("bh")
Dim mm As String = e.Cookies("mm") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("bh") AndAlso e.PostValues.ContainsKey("mm")  Then
        bh = e.PostValues("bh")
        mm = e.PostValues("mm")
        \'\' MessageBox.show("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"e5","ff") & "\'")
        Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"a5","erp") & "\'" )
        If tr IsNot Nothing Then

            Verified  = True
MessageBox.show("2")
            zh=tr("姓名")
        End If
        \'
    End If
End If

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

先弹出2 再弹出1 有点搞不懂

--  作者:有点蓝
--  发布时间:2017/9/20 17:31:00
--  
代码逻辑不正确,按照帮助做:http://www.foxtable.com/mobilehelp/scr/0138.htm
--  作者:rjh4078
--  发布时间:2017/9/20 17:34:00
--  
我就是按照帮助来做的 只是把相关控件名称和身份验证那部分代码做了修改
现在是先弹出2 然后弹出 false default.htm 

Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim zh As String = e.Cookies("zh") \'从cookie中获取用户名
Dim bh As String = e.Cookies("bh")
Dim mm As String = e.Cookies("mm") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("bh") AndAlso e.PostValues.ContainsKey("mm")  Then
        bh = e.PostValues("bh")
        mm = e.PostValues("mm")                \'
    End If
End If
If e.PostValues("bh")<>"" AndAlso e.PostValues("mm")<>"" Then
    Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & e.PostValues("bh") & "\' and 启用=1 and 密码=\'" & EncryptText(e.PostValues("mm"),"a5","erp") & "\'" )
    If tr IsNot Nothing Then
        Verified  = True
        zh=tr("姓名")
MessageBox.show("2")
    End If
End If


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

--  作者:有点蓝
--  发布时间:2017/9/20 17:54:00
--  
弹出编号和密码看看

Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim zh As String = e.Cookies("zh") \'从cookie中获取用户名
Dim bh As String = e.Cookies("bh")
Dim mm As String = e.Cookies("mm") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("bh") AndAlso e.PostValues.ContainsKey("mm")  Then
        bh = e.PostValues("bh")
        mm = e.PostValues("mm")                \'
    End If
End If
msgbox(bh)
msgbox(mm)
If bh > "" AndAlso mm > "" Then
    Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & bh & "\' and 启用=1 and 密码=\'" & EncryptText(mm,"a5","erp") & "\'" )
    If tr IsNot Nothing Then
        Verified  = True
        zh=tr("姓名")
        MessageBox.show("2")
    End If
End If


--  作者:rjh4078
--  发布时间:2017/9/20 18:27:00
--  
可以了 真是神奇
如果读取到cookies把用户名自动填到用户名栏目怎么写?

--  作者:rjh4078
--  发布时间:2017/9/20 19:21:00
--  
Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim zh As String = e.Cookies("zh") \'从cookie中获取用户名
Dim bh As String = e.Cookies("bh")
Dim mm As String = e.Cookies("mm") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("bh") AndAlso e.PostValues.ContainsKey("mm")  Then
        bh = e.PostValues("bh")
        mm = e.PostValues("mm")                \'
    End If
End If
MessageBox.show(mm)
If bh<>"" AndAlso mm<>"" Then
    Dim tr As DataRow=DataTables("人员表").sqlfind("编号=\'" & e.PostValues("bh") & "\' and 启用=1 and 密码=\'" & mm & "\'" )
    If tr IsNot Nothing Then
        Verified  = True
        zh=tr("姓名")
    End If
End If


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

我在将密码写入cookies的时候进行了加密  现在遇到一个问题 如果密码修改了 程序会一直以本地的密码来验证 怎么来改优先级呢

--  作者:有点甜
--  发布时间:2017/9/20 22:03:00
--  
以下是引用rjh4078在2017/9/20 19:21:00的发言:
 

我在将密码写入cookies的时候进行了加密  现在遇到一个问题 如果密码修改了 程序会一直以本地的密码来验证 怎么来改优先级呢

 

你修改密码以后,理应重新登陆一次的。现在的网站都是这样做的。