Change password, in fact very simple, the process is this, first enter the original password → Enter the new password → confirm the new password again, when the input is completed, when the click Change Password, start to verify, first of all, the original password is correct, the original password is correct under the premise, to determine whether the new password and the original password consistent, Inconsistent case to determine whether the new password two times the same, if the new password is consistent, then prompt the user to modify the password successfully, forcing users offline, because the main interface when the need to be prompted to close, it should be the user even choose not to exit the system, the situation should still exit the system, the specific code is as follows:
Dim MRC Asadodb.recordset
Dim TxtSQL, Msgtext as String
If OldPassword. Text = "" Then
MsgBox "Please enter your current password. ", vbOKOnly + vbinformation," prompt message "
OldPassword. SetFocus
ElseIf newpassword (0). Text = "" Then
MsgBox "Please enter a new password. ", vbOKOnly + vbinformation," prompt message "
NewPassword (0). SetFocus
ElseIf NewPassword (1). Text = "" Then
MsgBox "Please enter a new password. ", vbOKOnly + vbinformation," prompt message "
NewPassword (1). SetFocus
Else
' Determine if the original password is correct, if the new password is the same as the original password, the new password is consistent
TxtSQL = "SELECT * from User_infowhere userid= '" & UserName & "'"
Set MRC = ExecuteSQL (TxtSQL, Msgtext)
If Trim (MRC. Fields (1)) <>trim (OldPassword. Text) Then
MsgBox "Original password error, please re-enter. ", vbOKOnly +vbinformation," hint message "
OldPassword. Text = ""
OldPassword. SetFocus
ElseIf Trim (newpassword (0). Text) =trim (OldPassword. Text) Then
MsgBox "The old password cannot be the same as the new password. ", vbOKOnly +vbinformation," hint message "
NewPassword (0). Text = ""
NewPassword (0). SetFocus
ElseIf Trim (newpassword (0). Text) <> Trim (NewPassword (1). Text) Then
MsgBox "Please check the two times the input is consistent and re-enter. ", vbokonly+ vbinformation," hint message "
OldPassword. Text = ""
NewPassword (0). Text = ""
NewPassword (1). Text = ""
OldPassword. SetFocus
Else
' Change Password
Mrc. Fields (1) = NewPassword (0). Text
Mrc. Update
Mrc. Close
MsgBox "Password modified successfully, please log in to the system again. ", vbOKOnly," prompt message "
' Force the user to log off, re-login system
Dim frm as Form
For each frm in Forms
If frm. Name <> "Login" Then
Unload frm
If myexit = vbno Or myexit= vbyes Then
Cancel = False
End If
Frmmain.hide
Login.show
Login.txtpassword.Text = ""
Login.txtusername.Text = ""
End If
Next
End If
End If
When changing the password, we should ask the user to change the password after completion, force the user to re-login, the red font part of the code.
Summary: The computer room toll system does not have many too difficult places, just some small places, we need to improve, need to strengthen, so that the system more perfect, more adapt to the needs of users.