您的位置:首页 > 其它

机房收费系统-添加密保功能

2018-01-01 16:18 441 查看

起因

之前曾经和小伙伴讨论过关于机房收费系统的安全性的问题,如果忘了密码怎么办?

于是脑洞就来了,就联想到了QQ的密保功能!于是就开始干了

思路

密保用来找回密码,所以需要在数据库user_info中添加两个字段用来放置密保问题及密保答案!

找回密码按钮当然是放在登录窗体。

用户在设置完密保后还可以在主程序里面找到一个修改密保的入口!所以我就在菜单上添加了一个安全的菜单!

窗体的设计与修改密码的窗体大同小异!



实现

1、窗体







2、代码

其他的实现没有那么复杂!接下来看一下验证码的实现!

Private Sub drawvc()
Dim i, vc, px, py As Long
Dim r, g, b As Byte
Randomize
vc = CLng(8999 * Rnd + 1000)
vccode = vc
'显示检验码
Picture1.Cls
Picture1.Print vc
'添加噪点
For i = 0 To 2000
px = CLng(Picture1.Width * Rnd)
py = CLng(Picture.Height * Rnd)
r = CByte(255 * Rnd)
g = CByte(255 * Rnd)
b = CByte(255 * Rnd)
Picture1.Line (px, py)-(px + 1, py + 1), RGB(r, g, b)
Next
End Sub
Private Sub Picture1_Click()
drawvc

End Sub


修改密码

If Trim(txtusername.Text) = "" Then
MsgBox "请输入要找回的用户名!", vbOKOnly + vbExclamation, "提示"
txtusername.SetFocus
Else

If Trim(cmbencryptedquestion.Text) = "" Then
MsgBox "请选择密保问题!", vbOKOnly + vbExclamation, "提示"
cmbencryptedquestion.SetFocus
Else
If Trim(txtyanzhengma.Text) = "" Then
MsgBox "请输入验证码!", vbOKOnly + vbExclamation, "提示"
txtyanzhengma.SetFocus
Else
If Trim(txtyanzhengma.Text) <> vccode Then
MsgBox "验证码输入错误!", vbOKOnly + vbExclamation, "提示"
txtyanzhengma.Text = ""
txtyanzhengma.SetFocus
drawvc
Else
txtSQL = "select * from user_info where userid='" & Trim(txtusername.Text) & "'"
Set mrc = executeSQL(txtSQL, msgtext)
If mrc.EOF Then
MsgBox "没有该用户!", vbOKOnly + vbExclamation, "提示"
txtusername.Text = ""
txtusername.SetFocus
Else
If Trim(mrc.Fields(6)) <> Trim(cmbencryptedquestion.Text) Then
MsgBox "请选择正确的密保问题!"
cmbencryptedquestion.SetFocus
Else
If Trim(mrc.Fields(5)) <> Trim(txtencryptedanwser.Text) Then
MsgBox "请输入正确的密保答案!", vbOKOnly + vbExclamation, "提示"
txtencryptedanwser.Text = ""
txtencryptedanwser.SetFocus
micount = micount + 1
If micount = 3 Then
MsgBox "超过输入限制次数,系统即将关闭!", vbkonly + vbExclamation, "提示"
End
End If
Exit Sub
Else
mima = InputBox("请输入新密码!", "密码找回!")
mrc.Fields(1) = Trim(mima)
mrc.Update
MsgBox "密码已经重置,请您牢记密码!", vbOKOnly + vbInformation, "密码重置成功!"
Unload Me
End If
End If
End If
End If
End If
End If
End If


在这里用的是inputbox控件来承接用户输入的新密码!

总结

其实要实现这个功能很简单,但是我更觉得我们要经常有这种想法,无论是在哪个项目上,哪个系统上!可能敲代码很简单, 但是我们有想法更加重要!

感谢你的阅读!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: