'修改密码
Dim Verified As Boolean '身份验证判断
Dim UserName As String
Dim Password As String
Dim UserID As String
If e.Path = "xgmm.htm" '打开的是修改密码网页时
If e.PostValues.ContainsKey("oldpw") AndAlso e.PostValues.ContainsKey("newpw") Then
UserName = e.Cookies("username") '从cookie中获取用户名
UserID = e.Cookies("userid") '从cookie中获取随机ID
Dim dr As DataRow
dr = DataTables("在线用户").Find("UserName = '" & UserName & "'") '从在线用户表中获取相同用户名
If dr IsNot Nothing AndAlso dr("UserID") = UserID Then '如果找到相同ID用户的话
UserName = e.PostValues("username")
Password = e.PostValues("password")
'MessageBox.Show("name='"& username &"' And password='"& password &"'")
Dim s1 as string = e.PostValues("oldpw") '旧密码
Dim s2 as string = e.PostValues("newpw") '新密码
Dim drz As DataRow
drz = DataTables("用户").Find("UserName= '" & UserName & "'") '从用户表中获取用户名
If drz IsNot Nothing Then '如果找到
Verified = True '身份验证通过
End If
If Verified Then '身份验证通过后
If Password = s1 Then '输入的旧密码相同时
drz("Password") = drz("Password").replace(s1,s2) '用输入的新密码替换旧密码
drz.save '保存一下
wb.AddTopTips("","toptip1","修改完成,请重新登录!").msec = 2000
wb.InsertHTML("<meta http-equiv='Refresh' c>") '修改完成后直接跳转到登录面
e.WriteString(wb.Build) '生成网页
Return '必须的
Else '输入的旧密码错误提示
wb.AddTopTips("","toptip2","请输入正确的旧密码!").msec = 2000
End If
End If
End If
End If
End If