|
|
#1 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
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 |
|
I don't do your homework!
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
![]() ![]() |
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 |
|
in the borderlands
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
|
|
#4 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
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 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 54,243
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: password problem
Why are you showing a form after three unsuccessful attempts
Code:
If intCounter = 3 Then
Unload Me
frmMenu.Show
__________________
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 |
|
|
|
|
|
#6 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
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 |
|
|
|
|
|
#7 |
|
in the borderlands
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
|
|
#8 |
|
PowerPoster
Join Date: Feb 06
Location: East of NYC, USA
Posts: 5,692
![]() ![]() ![]() ![]() |
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 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 |
|
New Member
Join Date: Jun 07
Location: Cebu City
Posts: 13
![]() |
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 |
|
in the borderlands
Join Date: Feb 01
Location: in evansville, IN, recently highlighted in an at&t commercial
Posts: 6,752
![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|