To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Display Modes
Old Jun 19th, 2007, 11:40 PM   #1
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
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
matrik02 is offline   Reply With Quote
Old Jun 20th, 2007, 12:27 AM   #2
opus
I don't do your homework!
 
opus's Avatar
 
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
opus has a spectacular aura about (150+)opus has a spectacular aura about (150+)
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!
opus is offline   Reply With Quote
Old Jun 20th, 2007, 12:46 AM   #3
Lord Orwell
in the borderlands
 
Lord Orwell's Avatar
 
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)
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.
__________________
"While it is always best to believe in oneself, a little help from others can be a great blessing."
-Mako, Dragon of the West.
Follow me on twitter: lordorwell
Lord Orwell is offline   Reply With Quote
Old Jun 20th, 2007, 03:19 AM   #4
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
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.
matrik02 is offline   Reply With Quote
Old Jun 20th, 2007, 07:17 AM   #5
Hack
Super Moderator
 
Hack's Avatar
 
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)Hack has a brilliant future (2000+)
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?
__________________
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum.

Creating A Wizard In VB.NET
Modifications Required For VB6 Apps To Work On Vista
Paging A Recordset
What is wrong with using On Error Resume Next
Good Article: Language Enhancements In Visual Basic 2010
IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010
Hack is offline   Reply With Quote
Old Jun 20th, 2007, 08:01 AM   #6
matrik02
Frenzied Member
 
matrik02's Avatar
 
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
matrik02 is an unknown quantity at this point (<10)
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.
matrik02 is offline   Reply With Quote
Old Jun 20th, 2007, 02:38 PM   #7
Lord Orwell
in the borderlands
 
Lord Orwell's Avatar
 
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)
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)
__________________
"While it is always best to believe in oneself, a little help from others can be a great blessing."
-Mako, Dragon of the West.
Follow me on twitter: lordorwell
Lord Orwell is offline   Reply With Quote
Old Jun 20th, 2007, 05:01 PM   #8
Al42
PowerPoster
 
Join Date: Feb 06
Location: East of NYC, USA
Posts: 5,692
Al42 is a jewel in the rough (300+)Al42 is a jewel in the rough (300+)Al42 is a jewel in the rough (300+)Al42 is a jewel in the rough (300+)
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
Al42 is offline   Reply With Quote
Old Jun 20th, 2007, 06:58 PM   #9
jireh
New Member
 
Join Date: Jun 07
Location: Cebu City
Posts: 13
jireh is an unknown quantity at this point (<10)
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
jireh is offline   Reply With Quote
Old Jun 20th, 2007, 07:26 PM   #10
Lord Orwell
in the borderlands
 
Lord Orwell's Avatar
 
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)Lord Orwell is a glorious beacon of light (400+)
Re: password problem

you could always be violent and start the uninstall application on 3 wrong entries
__________________
"While it is always best to believe in oneself, a little help from others can be a great blessing."
-Mako, Dragon of the West.
Follow me on twitter: lordorwell
Lord Orwell is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:25 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.