Foxtable(狐表)用户栏目专家坐堂 → 移动端sql登录求助


  共有2012人关注过本帖树形打印复制链接

主题:移动端sql登录求助

帅哥哟,离线,有人找我吗?
188802386
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:629 积分:4915 威望:0 精华:0 注册:2014/2/25 15:50:00
移动端sql登录求助  发帖心情 Post By:2017/5/19 9:31:00 [只看该作者]

我想使用数据库来验证用户名和密码,但是却不成功,请老师帮忙看下问题出在那
Dim UserName As String = e.PostValues("username")
Dim Password As String = e.PostValues("password")
Dim UserID As String
If e.Path = "logon.htm" '验证用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        Dim Verified As Boolean '用于标记用户是否通过了身份验证
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
        'If UserName = "张三" AndAlso Password = "888" Then  '实际使用的时候,请改为从数据库读取用户名和密码进行比较
            'Verified  = True
End If
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "SELECT * Fr   om {员工管理} Where [Name] Is Null"
_UserTable = cmd.ExecuteReader(True) 
Dim UserName As String = e.Form.Controls("UserName").Value
Dim dr As DataRow
dr = _UserTable.SQLFind("[Name] = '" & UserName & "'") 
If dr IsNot Nothing Then
If e.Form.Controls("PassWord").Value = dr("Password") Then
Verified  = True
Else
End If
        End If

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106178 积分:540007 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/5/19 9:47:00 [只看该作者]

以示例用法为例说明:http://www.foxtable.com/mobilehelp/scr/0138.htm


......
'身份验证
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
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "SELECT * Fr   om {员工管理} Where [Name] ='" & UserName & "'"
Dim dt As DataTable = cmd.ExecuteReader()
If dt.DataRows.Count > 0 Then
    Dim dr As DataRow
    dr = dt.DataRows(0)
    If Password = dr("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

......

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/19 9:49:00 [只看该作者]

Dim UserName As String = e.PostValues("username")
Dim Password As String = e.PostValues("password")
If e.Path = "logon.htm" '验证用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        Dim Verified As Boolean '用于标记用户是否通过了身份验证
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
        'If UserName = "张三" AndAlso Password = "888" Then  '实际使用的时候,请改为从数据库读取用户名和密码进行比较
        'Verified  = True
        Dim cmd As New SQLCommand
        cmd.CommandText = "SELECT * From {员工管理} Where [Name] = '" & username & "'"
        _UserTable = cmd.ExecuteReader
        If _UserTable.DataRows.count > 0 Then
            If password = _userTable.DataRows(0)("password") Then
                Verified  = True
            End If
        End If
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
188802386
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:629 积分:4915 威望:0 精华:0 注册:2014/2/25 15:50:00
  发帖心情 Post By:2017/5/19 10:28:00 [只看该作者]

可以用http://www.foxtable.com/mobilehelp/index.htm?page=0138.htm这个例子为例吗,移动端肯定是要套用数据库的,建议官方出帮助教程就建议用数据库为基础来做,

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/19 10:32:00 [只看该作者]

 直接看2楼代码。


 回到顶部
帅哥哟,离线,有人找我吗?
188802386
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:629 积分:4915 威望:0 精华:0 注册:2014/2/25 15:50:00
  发帖心情 Post By:2017/5/19 11:37:00 [只看该作者]

错了 这个http://www.foxtable.com/mobilehelp/index.htm?page=0154.htm


 回到顶部
帅哥,在线噢!
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106178 积分:540007 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/5/19 12:06:00 [只看该作者]

还是2楼的用法,逻辑完全一样

 回到顶部