Results 1 to 10 of 10

Thread: [RESOLVED] password problem

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] password problem

    I have problem here, If I enter a wrong password in the textbox I got the message MsgBox "Please put correct password.", vbCritical, "WARNING", untill three times attempts, after three time unsuccessful attempt, this form unload and frmMenu.Show appear. This Ok to me

    If I enter the correct password, I got that message MsgBox "You successful enter the password" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang". This also Ok.

    But after enter a wrong password, this password form unload,Then I call the form again.. and this times, I try to enter the wrong password..I got the message
    MsgBox "Please put correct password.", vbCritical, "WARNING", althought I have put the wrong password more than 3 unsuccessful attempts.Why I still still got this error mesage despite I have done more than 3 unsuccessful attempts to enter the new form frmMenu.Show.
    Code:
    Private Sub cmdOK_Click()
     Set adoConn = New ADODB.Connection
        Set adoRS = New ADODB.Recordset
    
        Dim cs As String
            'cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\DBMS.mdb" & ";Persist Security Info=False;"
            cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "\DBMS.mdb" & ";Jet OLEDB:Database Password=macres;"
        adoConn.ConnectionString = cs
        adoConn.Open
    
    If Text2.Text = "" Then
    
            MsgBox "Please put your password", vbCritical, "Kata laluan"
         
            Text2.Text = ""
            Text2.SetFocus
    Else
        
         usrnm = Text2.Text
         adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';",   
         adoConn, adOpenStatic, adLockOptimistic
            
    
            
             If adoRS.Fields("Password").Value = Text2.Text Then
            pass = True
            'if password valid, success
            MsgBox "You successful enter the password" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
            Unload Me
            Form1.Show
            Unload frmMenu
            Else
        'if password invalid,message box ask to insert invalid password
           intCounter = intCounter + 1
           If intCounter = 3 Then
           Unload Me
           frmMenu.Show
         Else
         MsgBox "Please put correct password.", vbCritical, "WARNING"
         Text2.Text = ""
         Text2.SetFocus
    
        End If
        End If
     End If
    End Sub

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: password problem

    If I understand correctly, you problem comes after having entered the wrong password 3 times, the password-form has been unloaded and then you areable to show the password-form again.

    The password-form will correctly accept another 3 tries, as it would for each and every time you call it to show.

    You would need to make sure that you can not recall this form if it has been called before. However that same situation would be there if one user loggs off and another one tries to logg in, would you wnat to accept that?
    If you will only allow one user to enter during one runtime, just let the password-form be shown only once (use a counter or boolean in the routine where you cal the password-form.show).
    If you allow the situation that other users could logg during the runtime off your application, I don't see a way to do that.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: password problem

    best method is to lock the program for a set time (say 2 minutes) from letting you click the button that shows the password form. This will prevent random brute force hacking and allow someone that really did mess up on accident to try again.

    The reason it lets you try over and over is when you unload the form, you erase the variable you are storing the count in. Move the variable into a module, and you can load and unload the form all day long and it will still have the same count. Method above is better though.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: password problem

    how to set a time after unsuccessul attempts?have a sample for that?

    After unsuccessul attempts for ore than 3 times, the password unload (mean the user cannot enter that module.. It ok.. Then When I try again... the message box Please put correct password always appear every time I enter invalid password despite I have enter the invalid password more than 3 times. It suppose unload after 3 times unsuccessul attempts.. The the first action it ok..But when I try back...the messagebox always appear and I need try it over and over untill I enter the valid password.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: password problem

    Why are you showing a form after three unsuccessful attempts
    Code:
      If intCounter = 3 Then
           Unload Me
           frmMenu.Show
    If it hits three the program should completely unload itself, right?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: password problem

    Actually, I have 3 form.. Form1, frmMenu and password form.. The code is extract from the OK button in password form.. If three unsuccessful attempts, the password form unload and password frmMenu will appear.. But If the password is valid, then Form1 will appear..For the first, I did not get the problem when I try three times unsuccessful attempts, the password form will unload and frmMenu will appear.The message box MsgBox "Please put correct password.", vbCritical, "WARNING" only promote three time.After
    Code:
     If intCounter = 3 Then 
    Unload Me
    frmMenu.Show
    that the password form unload and frmMenu appear. Then.. I try call the password form again to be appear, this time I try three time unsuccessful attempts with hope that I got the same result as the first, but this time, I got the problem, it always promote the MsgBox "Please put correct password.", vbCritical, "WARNING" more than three time despite I have put the invalid password more then three attempts but still always got the promote message box. It suppose unload after three attempts.So to not recieve the message box, I have force myself to enter the valid password.. and then it I did not recieve the message box again and form 1 appear and unload the password form.

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: password problem

    shouldn't you be showing the form BEFORE unloading the other one? This could be interfering with the unload.

    To set a timer for click again, put a code in the button that checks the built-in Timer variable against a stored number. 100 timers = 1 second.
    so if you have a global variable named "StoredTim" when they have failed on the 3rd attempt you would do this: StoredTim = Timer
    then in the click event : If Timer - StoredTim < 18000 then exit sub

    This is an industry standard way of locking input: A time delay. Windows uses it itself on the password screen. (secure versions that is)
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: password problem

    Fixing the problem of the form loading and allowing 3 more tries is just a scope problem. But you have to decide whether the user has to close the whole program to try again, or whether you're going to allow it to work the way it does now. You can't stop one user from trying to log in after 3 tries, but allow another user to try to log in at that point - the computer doesn't know who's typing.

    To keep the program from allowing more than 3 tries, define your counter variable in a module
    Code:
    Public intCounter As Integer
    In the code where you show the login window (probably frmMain)
    Code:
    If intCounter < 3 Then
      frmLogin.Show 'use whatever the real form name is
    Else
      MsgBox "Sorry, you've had 3 tries.",vbCritical
    End If
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  9. #9
    New Member
    Join Date
    Jun 2007
    Location
    Cebu City
    Posts
    13

    Wink Re: password problem

    option explicit
    Static cntr as Integer

    Private Sub OKBtn_Click()
    Dim db as Database ---for your database
    Dim rs as Recordset - for password table

    Set db=... open your db
    set rs=... open the password table and look for the username
    if not rs.BOF then '... if it exist
    if rs!password=txtpassword.text Then '...if password is correct
    unload me
    frmMenu.Show
    else
    msgbox "Access denied.",vbExclamation,"Warning"
    cntr=cntr + 1
    end if
    else
    msgbox "Access denied.",vbExclamation,"Warning"
    cntr=cntr + 1
    end if

    counterResult:
    if cntr = 3 then
    ...put here whatever your condition is.
    cntr = 0
    end if
    End Sub



    Hope it could help or give you an idea...hekhek

    regards:

    jireh

  10. #10
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: password problem

    you could always be violent and start the uninstall application on 3 wrong entries
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

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



Click Here to Expand Forum to Full Width