Computer room charge System--Change Password

Source: Internet
Author: User
Tags trim

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.