验证用户名和密码
来源:互联网 发布:老九门 知乎 编辑:程序博客网 时间:2024/04/29 13:38
1、
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=StoreHouseMaster;Data Source=IBM"
conn.open
rs.open "select * from operator where user_name='" & username.text & "' and userpassword='" & userpassword.text & "'",conn
if rs.eof then
msgbox "密码错误!"
else
msgbox "密码正确!"
end if
2、
上面的代码有安全性问题啊
可以在username里面输入字串“1 or 1=1 --”就可以跳过密码检测
rs.open "select userpassword from operator where user_name='" & username.text & "'"
if rs(0)=userpassword.text then
msgbox "密码错误!"
else
msgbox "密码正确!"
end if
还要考虑用户不合法的情况:
rs.open "select userpassword from operator where user_name='" & username.text & "'"
if rs.recordcount=0 then
msgbox "用户不存在!"
elseif rs(0)<>userpassword.text then
msgbox "密码错误!"
else
msgbox "密码正确!"
end if
3。
Private Sub Command1_Click() '登陆
On Error GoTo Err
If UserName.Text = "" Then
MsgBox "请输入操作员!", vbInformation, "提示"
Exit Sub
End If
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=StoreHouseMaster;Data Source=IBM"
cn.Open
rs.CursorLocation = adUseClient
Dim name As String, passa As String
name = Trim(UserName.Text)
passa = Trim(userpassword.Text)
rs.Open "select * from Operator where user_name='" & name & "'", cn, adOpenKeyset, adLockReadOnly
If rs.EOF Then
MsgBox "该用户尚未注册!", vbOKCancel, "提示"
UserName.SetFocus
UserName.SelStart = 0
UserName.SelLength = Len(UserName.Text)
Exit Sub
Else
If passa <> Trim(rs!userpassword) Then
MsgBox "密码不正确,请重输!!!", vbQuestion, "提示"
userpassword.Text = ""
userpassword.SetFocus
Exit Sub
End If
Me.Hide
main.Show 'main为主窗口名称
Exit Sub
Err:
MsgBox Err.Description
End Sub
- 验证用户名和密码
- 用户名和密码验证
- 用户名和密码验证问题
- JQuery验证用户名和密码
- Apache用户名和密码验证
- apache用户名和密码验证
- 验证用户名、密码和日期
- Ajax验证用户名和密码
- 用户名和密码正则验证。
- jsp验证用户名和密码
- MVC数据验证--用户名和密码验证
- wcf 用户名密码验证和证书验证
- 登录用户名和密码的验证
- php用户名和密码的简单验证
- CXF 通过用户名和密码进行验证
- [C#]LDAP验证用户名和密码
- PHP验证登录用户名和密码
- PHP验证登录用户名和密码
- 可按任意字段排序的分页存储过程
- 全面认识JAVA
- 写给自己看的,理解J2EE,总结自己的学习
- test for firefox and opera
- Visual C++ 入门精解(转自PCONLINE 作者:管宁)
- 验证用户名和密码
- 有用的操作系统环境函数“Environ”
- 五句可以分享的话
- C++多参数模板偏特化
- 学习CSS布局的一些思路
- Unicode简介(转)
- 安装Linux9+httpd-2.0.52+tomcat-5.0.28+mod_jk2步骤
- 处理器外频
- 原创-IBM DB2学习笔记-1:日期以及时间的使用