以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  登录页面,输入正确的验证码,验证不成功  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=98069)

--  作者:zhangjian222200
--  发布时间:2017/3/23 15:29:00
--  登录页面,输入正确的验证码,验证不成功
登录页面,输入正确的验证码,验证不成功,应该是cookies的问题,详情见下面粉色代码,麻烦看看
获取验证码、js代码发不上来,所以放在文档里

图片点击可在新窗口打开查看此主题相关图片如下:qq图片201111111111.png
图片点击可在新窗口打开查看

这是登录页面login.htm代码:
Dim e As RequestEventArgs = args(0)                             \'登录页面
Select Case e.Path
    Case "login.htm"
        Dim wb As New weui
        If e.PostValues.Count = 0 Then
            wb.AddTopTips("","toptip1","") \'用于显示动态错误提示
            wb.AddForm("","form1","valid_login.htm").Attribute="on-sub-mit=\'return validit_login()\'"
            With wb.AddInputGroup("form1","ipg1","登录")
                If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm")  Then \'判断是否是验证失败后的重新登录
                    wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示.
                End If
                With .AddInputCell("ic1")  \'通过InputCell增加输入框(1表示突出显示,2表示红色警示图标)
                    .AddLabel("lsj","手机",0)  \'增加标签(0显示在左边)
                    .AddInput("isj","text",1).PlaceHolder= "请输入手机号"  \'增加输入框(0靠左显示,1居中显示,2靠右显示)
                End With
                With .AddInputCell("ic2")
                    .AddLabel("lmm","密码",0)
                    .AddInput("imm","password",1).PlaceHolder= "请输入密码"
                End With
                With .AddInputCell("ic5") \'通过InputCell增加输入框
                    .AddLabel("lyzm","验证码",0) \'增加标签,0显示在左边
                    .AddInput("yzm","text",1) \'增加输入框,1表示显示在中间
                    .AddImage("pim","/getVimg.htm",2).Attribute="o-n-click=""this.src = \'getVimg.htm?rand=\' + Math.random() """ \'增加一个图片,2比表示显示在右边
                End With
                \'End With
                .AddSwitch("jizhumima","记住密码")
                With wb.AddButtonGroup("form1","btg1",True)
                    .Add("btn1", "登录","submit") \'"/index.htm")
                End With
                With wb.AddButtonGroup("form1","btg2", False)
                    .Add("btn2", "免费注册","","/register.htm").Kind = 1
                    .Add("btn3", "忘记密码","","/getback.htm").Kind = 1
                End With
            End With
            wb.AppendHTML("<s-crip-t src=\'./lib/ajaxform_login.js\'></script>") \'引入脚本文件
            e.WriteString(wb.Build) \'生成网页
        End If
End Select

这是登录验证valid_login.htm页面代码:
Dim e As RequestEventArgs = args(0)                             \'验证页面(登录页面)
Select Case e.Path
    Case "valid_login.htm"
        Dim wb As New weui
        Dim cookie_yzm As String = e.Cookies("msg") \'从cookie中获取验证码
        msgbox(e.Cookies("msg"))     ’窗口弹出,无值
        msgbox(cookie_yzm)             ‘同上
        Dim yanzm As String = e.PostValues("yzm") \'验证_验证码
        Dim jizmm As String = e.PostValues("jizhumima") \'验证服务协议
        If yanzm = "" Then
            e.WriteString("验证码不能为空!")
            Return ""
        ElseIf yanzm <> "" AndAlso yanzm.Length <> 4 Then
            e.WriteString("请输入正确的验证码!")
            Return ""
        ElseIf yanzm <> " & cookie_yzm & "  Then
            msgbox(123)                                       ‘窗口弹出123         ’
            e.WriteString("请输入正确的验证码!")
            Return ""
        End If
End Select
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:获取验证码、js代码.txt


[此贴子已经被作者于2017/3/23 15:34:44编辑过]

--  作者:有点色
--  发布时间:2017/3/23 15:47:00
--  

getVImg设置的是这个啊 e.AppendCookie("yanzhengma", msg)  \'校对这个cookie

 

你要用这个名字啊 yanzhengma


--  作者:zhangjian222200
--  发布时间:2017/3/23 18:57:00
--  
1楼问题解决了,这是新问题

记住密码行,当勾选时,验证正常,当不勾选时,提示:未应用到实例(是不是因为涉及ajax,公测时,这里就有个bug的,后来改了,不知道这里的问题是不是又一个bug)
.AddSwitch("jizhumima","记住密码").Value = "是"  

js代码:
function validit_login(){
    var result=submitAjaxFileds("valid_login.htm","","isj","imm","yzm","jizhumima",false);
    if(result=="OK"){
        return true;
    }
    else{
        showTopTips("toptip1",result,2000);
        return false;
    }
}

[此贴子已经被作者于2017/3/23 21:39:44编辑过]

--  作者:有点色
--  发布时间:2017/3/23 21:04:00
--  

 

请加入msgbox弹出值定位错误位置。

 


--  作者:zhangjian222200
--  发布时间:2017/3/23 21:35:00
--  
这是内部函数login,js代码在3楼
Dim e As RequestEventArgs = args(0)                             \'登录页面
Select Case e.Path
    Case "login.htm"
        Dim wb As New weui
        If e.PostValues.Count = 0 Then
            wb.AddTopTips("","toptip1","") \'用于显示动态错误提示
            wb.AddForm("","form1","login.htm").Attribute=""
            With wb.AddInputGroup("form1","ipg1","登录")
                If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm")  Then \'判断是否是验证失败后的重新登录
                    wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示.
                End If
                With .AddInputCell("ic1")  \'通过InputCell增加输入框(1表示突出显示,2表示红色警示图标)
                    .AddLabel("lsj","手机",0)  \'增加标签(0显示在左边)
                    .AddInput("isj","text",1).PlaceHolder= "请输入手机号"  \'增加输入框(0靠左显示,1居中显示,2靠右显示)
                End With
                With .AddInputCell("ic2")
                    .AddLabel("lmm","密码",0)
                    .AddInput("imm","password",1).PlaceHolder= "请输入密码"
                End With
                With .AddInputCell("ic5") \'通过InputCell增加输入框
                    .AddLabel("lyzm","验证码",0) \'增加标签,0显示在左边
                    .AddInput("yzm","text",1) \'增加输入框,1表示显示在中间
                    .AddImage("pim","/getVimg.htm",2).Attribute=""" \'增加一个图片,2比表示显示在右边
                End With
                \'End With
                .AddSwitch("jizhumima","记住密码").Value = "是"   \'当不勾选时,有bug所有此行暂不用
                With wb.AddButtonGroup("form1","btg1",True)
                    .Add("btn1", "登录","submit") \'"/index.htm")
                End With
                With wb.AddButtonGroup("form1","btg2", False)
                    .Add("btn2", "免费注册","","/register.htm").Kind = 1
                    .Add("btn3", "忘记密码","","/getback.htm").Kind = 1
                End With
            End With
            wb.AppendHTML("<script src=\'./lib/ajaxform_login.js\'></script>") \'引入脚本文件
            e.WriteString(wb.Build) \'生成网页
        End If
End Select

这是内部函数valid_login,当不勾选时,msgbox("是否已经记住密码:" & jizmm)弹出空值,见下图
Dim e As RequestEventArgs = args(0)                             \'验证页面(登录页面)
Select Case e.Path
    Case "valid_login.htm"
        Dim wb As New weui
        Dim shoujh As String = e.PostValues("isj") \'验证手机是否空值
        msgbox("手机:" & shoujh)
        Dim mim As String = e.PostValues("imm") \'验证密码是否空值
        msgbox("密码:" & mim)
        Dim cookie_yzm As String = e.Cookies("yanzhengma") \'从cookie中获取验证码
        msgbox(e.Cookies("yanzhengma"))
        msgbox("cookie验证码:" & cookie_yzm)
        Dim yanzm As String = e.PostValues("yzm") \'验证_验证码
        msgbox("输入的验证码:" & yanzm)
        Dim jizmm As String = e.PostValues("jizhumima") \'验证_记住密码
        msgbox("记住密码:" & jizmm)
        If shoujh = "" Then
            e.WriteString("手机不能为空!")
            Return ""
        ElseIf mim = "" Then
            e.WriteString("密码不能为空!")
            Return ""
        ElseIf yanzm = "" Then
            e.WriteString("验证码不能为空!")
            Return ""
        ElseIf yanzm <> "" AndAlso yanzm.Length <> 4 Then
            e.WriteString("请输入正确的验证码!")
            Return ""
        ElseIf yanzm <>  cookie_yzm Then
            e.WriteString("请输入正确的验证码!")
            Return ""
        ElseIf jizmm <> "是" Then
            msgbox("是否已经记住密码:" & jizmm)
            \'e.WriteString("未确认服务协议!")
            Return ""
        End If
End Select

图片点击可在新窗口打开查看此主题相关图片如下:qq图片201703232129418888888.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2017/3/23 21:36:21编辑过]

--  作者:有点色
--  发布时间:2017/3/23 21:56:00
--  

 那没问题啊,弹出空值正常啊。

 

 记住密码本身就不需要验证,验证通过,那就返回OK。


--  作者:zhangjian222200
--  发布时间:2017/3/23 22:04:00
--  
可能之前弄错了,之前不勾选时弹出,提示:未应用到实例
--  作者:有点蓝
--  发布时间:2017/3/24 8:27:00
--  
运行到哪个msgbox弹出的错误?