您的位置:首页 > 其它

机房收费系统—登录

2016-08-21 22:35 239 查看
机房收费系统已经敲了一段时间内,现在来整理一下登录窗体的思路。





1.如果一个用户登录了系统,会向OnWork表中插入一条数据,向workLog表中插入一条 记录。

若正常退出,会删除OnWork表中这个记录 ,更改workLog表为下班状态。

若非正常退出(突然断电,关机,重启),用户则不能再登录这个系统。

方法:1.更改数据库的数据,但这个方法比较麻烦。

2.设置一个二次登陆密码,当用户重新登录时可以用这个(但是这个密码不能随 便告诉其他人)。

If Trim(txtUsername.Text = "") Then
MsgBox "用户名不能为空,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUsername.SetFocus
txtUsername.Text = ""
txtPassword.Text = ""
End If

txtSQL2 = "select * from onwork_info where userID='" & txtUsername.Text & "'"
Set mrc2 = ExecuteSQL(txtSQL2, MsgText2)

If mrc2.EOF = False Then   '如有上机记录
MsgBox "该用户正在登录,请稍后登录!", vbOKOnly + vbExclamation, "提示"
Exit Sub
Else
txtSQL = "select * from user_info where userID= '" & txtUsername.Text & "'"   '查询指定用户名的记录
Set mrc = ExecuteSQL(txtSQL, msgText)

If mrc.EOF Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "提示"
txtUsername.SetFocus
txtUsername.Text = ""
txtPassword.Text = ""
Exit Sub
Else

If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
Me.Hide
userName = Trim(txtUsername.Text)

Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "提示"
txtPassword.Text = ""
txtPassword.SetFocus
Exit Sub
End If
'向onwork中添加工作纪律
mrc2.AddNew
mrc2.Fields(0) = txtUsername.Text
mrc2.Fields(1) = mrc.Fields(2)
mrc2.Fields(2) = Date
mrc2.Fields(3) = Time
mrc2.Fields(4) = Trim(Environ("computername"))
mrc2.Update
mrc2.Close

'在能够登陆的情况下网worklog表里添加记录
txtSQL3 = "select * from worklog_info"
Set mrc3 = ExecuteSQL(txtSQL3, MsgText3)
mrc3.AddNew
mrc3.Fields(1) = userName
mrc3.Fields(2) = mrc.Fields(2)
mrc3.Fields(3) = Date
mrc3.Fields(4) = Time
mrc3.Fields(7) = Trim(Environ("computername"))
mrc3.Fields(8) = "true"
mrc3.Update
mrc3.Close
mrc.Close

End If
End If


2.SQL注入:SQL注入就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令,这样很容易导致信息的泄露,所以限制字符是必须的。

Private Sub txtUsername_KeyPress(KeyAscii As Integer)
'防止SQL注入
If KeyAscii > 31 And KeyAscii < 48 Or KeyAscii > 57 And KeyAscii < 65 Or KeyAscii > 90 And KeyAscii < 97 Or KeyAscii > 122 And KeyAscii < 127 Then
MsgBox "不能输入特殊字符,请输入数字或字母", vbOKOnly + vbExclamation, "警告"
KeyAscii = 0   '使输入的特殊字符为空字符
End If
End Sub

3.密码应该设置为暗码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: