我的问题:登录页面,需要验证手机号、密码、验证码是否为空,调用函数后,发现执行valid_login内部函数后,不执行后面的登录代码了,是不是需要验证页面返回什么值?
httprequest的代码逻辑说明:这样设置不需要验证的页面后,当不执行验证登录页面手机号、密码、验证码是否为空时,登录成功,1~7连续执行
if
e.path = “需要验证的页面”
else
e.path = “不需要验证的页面”
end if
以下是httprequest事件代码:
Select Case e.Path
Case "valid_login.htm" '调用,登录_验证手机号、密码、验证码是否为空页面
Functions.Execute("valid_login",e)
End Select
If e.Path = "login.htm" Then ’这以下是登录验证代码
Dim wb As New weui
msgbox(1)
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("isj") '从cookie中获取用户名
Dim Password As String = e.Cookies("imm") '从cookie中获取用户密码
msgbox(2)
If e.Path = "login.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
msgbox(3)
If e.PostValues.ContainsKey("isj") AndAlso e.PostValues.ContainsKey("imm") Then
msgbox(4)
UserName = e.PostValues("isj")
Password = e.PostValues("imm")
End If
End If
If e.Cookies.ContainsKey("isj") = False OrElse e.Cookies.ContainsKey("imm") = False Then
msgbox(5)
Dim dr As DataRow = DataTables("会员资料").Find("手机 = '" & UserName & "'")
If dr IsNot Nothing AndAlso dr("密码") = Password Then
msgbox(6)
Verified = True
End If
End If
If Verified AndAlso e.Path = "login.htm" Then '如果用户访问的是登录页,且身份验证成功
msgbox(7)
wb.AppendCookie("isj",UserName) '将用户名和密码写入cookie
wb.AppendCookie("imm",Password)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
e.WriteString(wb.Build) '生成网页
Return '必须的
ElseIf Verified = False AndAlso e.Path <> "login.htm" Then '如果用户身份验证失败,且访问的不是登录页面
msgbox(8)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
Select Case e.Path
Case "login.htm" '登录页面
Functions.Execute("login",e)
Case ****其他页面
End Select
Else
Select Case e.Path
Case "index.htm" '首页
Functions.Execute("index",e)
Case ****其他页面
End Select
End If
以下是内部函数valid_login的代码:能够正常验证,是不是需要返回什么值?
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_yzm)
Dim yanzm As String = e.PostValues("yzm") '验证_验证码
msgbox(yanzm)
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
msgbox(123)
e.WriteString("请输入正确的验证码!")
Return ""
End If
End Select
以下是js文件代码:
function validit_login(){
var result=submitAjaxFileds("valid_login.htm","","isj","imm","yzm",false);
if(result=="OK"){
return true;
}
else{
showTopTips("toptip1",result,2000);
return false;
}
}
[此贴子已经被作者于2017/3/23 20:33:45编辑过]