Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2005
    Posts
    5

    Talking Unanswered: I need help creating a login dialog box

    i have created a table with field names: "User Name" and "Password" and i had added "admin" and "user1" and "user2" for "User Name" and gave them a password. I created a form that displays two text boxes one for "User Name" and the other for "Password" my question is how do i get the text entered in the box to go and search the table and validate the "User Name" and "Password"?

  2. #2
    Join Date
    Oct 2004
    Location
    Cavite,Philippines
    Posts
    31
    try to assign the value to a variable

  3. #3
    Join Date
    Nov 2004
    Posts
    108
    VB6 comes with a login form (with code)

    if you are going to validate against a DB then you should use a SP to avoid SQL injection
    to err is human ; to really mess things up requires a computer

  4. #4
    Join Date
    Jan 2005
    Posts
    5
    i'm kinda new at this stuff, but i want to learn it so if someone can point me in the right direction i think i can take it from there

  5. #5
    Join Date
    Feb 2004
    Posts
    59

    here's what i did

    here's what i did:

    Table contains ID | Username | Password > Username is INDEXED with No Duplicates Allowed
    The FORM has two textboxes "txtUsername" and "txtPassword", and a button named "btnGo"

    I assume you've already got the db (database) and rs opened correctly, and pointed to your correct table.

    on the "Go" button (button click event) I have the following code:

    Private Sub btnGo_Click ()
    rs.Index = "Username" ' this will set the index of the table = Username
    rs.Seek "=", txtUsername
    If rs.NoMatch 'If the username isn't valid
    MsgBox "Username not found, please retry", vbokonly + vbexclamation, "Invalid Username"
    txtUsername.Text = "" 'clears invalid username from the form
    txtUsername.SetFocus 'puts the focus on the form, to the un txtbox
    Else:
    Call PasswordCheck
    End If
    End Sub

    Private Sub PasswordCheck ()
    If rs!Password <> txtPassword.Text Then 'Checks the textbox pwrd versus the one stored in the table
    MsgBox "Password is invalid, please try again", vbokonly + vbexclamation, "Password Invalid"
    txtPassword.Text = "" 'clears the invalid pwrd from the form's textbox
    txtPassword.SetFocus 'puts the focus on the form, to the Pwd txtbox
    Else:
    frmNewWindow.Show (Modal), frmOriginalWindowName

    End If

    rs.close
    End Sub

    I also have if/then statements with mine, to check for null values (if the username or password textboxes on the form are blank), to prompt and set the appropriate focus, but didn't include it here.

    This setup will do three things:
    1) Check for a valid username in the table "tblUsersData"
    2) If a username is not found, it will prompt, and set the focus back to the usrename textbox on the form
    2b) If a username IS found, it will check the password with the one on the table
    3) If the password in the table is not correct with the username, it will prompt and set the focus to the password box on the table
    3b) If the password is matched with the username in the table correctly, it will open the form named: NewWindow over the current form (frmOriginalWindowName)

    Please repost and let us know how this went!
    Last edited by mateo107; 01-28-05 at 21:58.
    -Matt H-
    www.comperfection.com

  6. #6
    Join Date
    Jan 2005
    Posts
    5
    I hate to sound stupid but what does "rs" stand for?

  7. #7
    Join Date
    Feb 2004
    Posts
    59
    rs is my declared recordset

    you can subsitute that for your recordset
    -Matt H-
    www.comperfection.com

  8. #8
    Join Date
    Jan 2005
    Posts
    5
    I get a runtime error 424 object required

    couldn't i use a select case and have usernames as case's?

  9. #9
    Join Date
    Jan 2005
    Posts
    18
    Hi

    I think u would not have declared that recordset

  10. #10
    Join Date
    Oct 2004
    Posts
    13
    I'd just install the ADO Component/Reference (goto Prerferences and Components, and browse/add anything that shows the most up to date ADO files).

    Then I'd drag the instance on the tool bar, the ADO button, onto the form, right mouse click, and choose to point it to an Microsoft Access database file (mdb). I would then put on several text boxes, link them to the datasource (whatever the ado is pointed at), and the datafield (ie UserName or Password).

    I'd then create a submit button to update the ado field with. (adoBLAH.Update).

    That's a start. Look for tutorials online about ADO controls.

  11. #11
    Join Date
    Feb 2005
    Posts
    2

    Question Creating login screens in VB6

    I didn't find creating login screens and saving the data in access database difficult...

    I was wondering if there is any other way we could do that, i mean saving the username and passwords in any other file rather than a database and encrypting the same...

    Rgds

    Sidz
    hotsid_rout@yahoo.com

  12. #12
    Join Date
    Oct 2004
    Posts
    13
    Quote Originally Posted by koolsid
    I didn't find creating login screens and saving the data in access database difficult...

    I was wondering if there is any other way we could do that, i mean saving the username and passwords in any other file rather than a database and encrypting the same...
    Have you looked into ADO's password and username fields? You can make it so only a specific person can log into the form or screen under a specified password in the properties field...

    Hm, you could create an external file with usernames and passwords... Depends on how much patience you have in reading it in, decrypting it, and such.

    For the most secure to do it all, I'd just make sure no one has access to the database and store it all there (which is what I think you're trying to avoid).

  13. #13
    Join Date
    Feb 2005
    Posts
    2

    login screens

    yes sam i was trying to avoid that... however my problem is solved

    anyways

    Hi jellyfishrm

    i am assuming that your problem is solved.... in case it isn't just lemme know, i'll paste the code here...
    Last edited by koolsid; 02-11-05 at 16:23.

  14. #14
    Join Date
    Jan 2005
    Posts
    5
    got it figured out



    Peace and Prosperity

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •