• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

Writing code for password and Log on verification

I would like to create code for password and username for system users to log on to the system.This code has to verify and see if the type password or username is in the already created list on the database table for log on.It should check and see if the typed password corresponds to the one on the list else  it displays an error message.
  • 3
  • 3
  • 2
  • +5
1 Solution
humbk2002Author Commented:
Please this code should be in visual basic for applications  for a standalone computer.
Ryan ChongCommented:

What Database are you using?

* And please do to rise some points as 50 pts = easy question :)

While agreeing with ryancys, some code to start with:
You have a form with to fields, username(txtUser) and password(txtMdp), and a button to validate the input.
Private Sub btnValider_Click()
On Error GoTo errhandl

      Dim rstUsers As New ADODB.Recordset
      Dim strSQLUsers As String
      Set rstUsers = Nothing
        strSQLUsers = "SELECT * FROM tblUsers WHERE Users = '" & txtUser & "'"
        rstUsers.Open strSQLUsers, cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
        If rstUsers!mdp = txtMdp Or rstUsers!users = "sa" Then
            usernom = txtUser
            btnStart.Visible = True
            If rstUsers!Edit = False Then
                Dim retmsg
                retmsg = MsgBox("You don't have the right to save records. Contact a sysadmin.", vbInformation, "Attention")
                'code to insert
            End If
            MsgBox "Who are you...?"
        End If
    Exit Sub
MsgBox "Try another name, one the system recognizes..."
End Sub

ANYWAY, you got to be connected to the database first: so OnLoad of your frmLogin you use the function below.

Public Function Connect()

    On Error GoTo errfind
    Set cn = New ADODB.Connection
    With cn
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=disk:\directory\yourdatabase.mdb"

    End With

end function

This is pretty basic stuff. Normally you should encrypt the password and decrypt it on the fly so it won't stay clear in the database.

I could send you code for that for two more points ;-))


Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

humbk2002Author Commented:
We use access for windows 2000 as the database
do you really expect to get a useful answer for ONLY 4 points?  You MUST be kidding.
humbk2002Author Commented:
I want a single block of code not separate procedure and a function.You saying I should encrypt the password and decrypt it on the fly so it wont stay clear in the database,you know i use vb 6.0 for application so if you use a text box ,then go to its properties then you have access to enter a password character,thus it can be encrypted.I want a code that contains the loading of the database at the same time with creating verification of passwords.
What was meant by "encrypt and de-crypt" is the you DO NOT want to have the Password, as stored in the DATABASE, to be readable - by simply opening the database table.  When you add a PasswordCharacter to a Text box, the password IS NOT encrypted, but rather for each character in the password, as it is entered by the user on that form the entered character is simply replaced, ON THE SCREEN, with the password character.  The value of the TextBox.Text property IS STILL THE PASSWORD, as entered by the user.

If you do not encrypt the password, as stored in the database table itself, then anyone can open the User table and view the Passwords for every user in the system.  That is a MAJOR SECURITY hole.  Not even the System Manager should know what a User's passwrod is.
and 6 points is RIDICULOUSLY low.  Be Serious.
This looks like yet another case of "Please do my homework for me".
Humbk2002 seems to be new around here. Suppose he didn't have the time to read the guidelines.

btw Just a remark.
Never put all your code in one block, keep procedures, subs and other functions separated. Creating a public function allows to reuse a block of code instead of having to rewrite it.


10 open questions, many are far below the minimum for easy questions of 50 points.  The maximum per question is 500 points.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
POINTS FOR EXPERTS awaiting comments are listed in the link below
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
humbk2002, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Accept Rem's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
Finalized as proposed


Community Support Moderator
Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now