3 Replies - 1559 Views - Last Post: 19 November 2009 - 05:48 AM Rate Topic: -----

#1 rob2y_k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-November 09

any idea on how to do the extreme login?

Posted 19 November 2009 - 03:44 AM

Hi..i need some help from those VB.Net expert.
I have already create a login code and form. but now, i would like to do some improvement in my login by doing some extreme login. so everytime the users put invalid username or password for let say three times, the system will quit and starts from the beginning again. any idea on how to do this?
thanks before!!


here my code :
Public Class frmLogin

	Private Sub CmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCancel.Click
		Dim hasil As MsgBoxResult

		hasil = MessageBox.Show("Are you sure want to exit from this system ?", "Exit system", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
		If hasil = MsgBoxResult.Yes Then
			End
		Else
			txtUsername.Focus()
		End If
	End Sub

	Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		txtUsername.Clear()
		txtPassword.Clear()
		txtUsername.Focus()
	End Sub

	Private Sub txtUsername_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUsername.KeyPress
		If Asc(e.KeyChar) = 13 Then
			txtUsername.Focus()
		End If
	End Sub


	Private Sub txtPassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassword.KeyPress
		If Asc(e.KeyChar) = 13 Then
			CmdOk.PerformClick()
		End If
	End Sub

	Private Sub CmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdOk.Click
		Dim fmCashier As New frmCashier
		Dim fmMDI As New frmMDI
		Dim Sql$
		Dim strs As String = ""
		Dim pwd As String = ""

		Dim com As New SqlClient.SqlCommand
		Dim reader As SqlClient.SqlDataReader = Nothing

		If txtUsername.Text.Trim = "" Then
			MessageBox.Show("Please enter the Username", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Focus()
			Exit Sub
		End If

		If txtPassword.Text.Trim = "" Then
			Call MessageBox.Show("Please enter the Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtPassword.Focus()
			Exit Sub
		End If

		Sql = "SELECT * FROM " & TBLUSERNAME
		Sql = Sql & " WHERE USERNAME='" & txtUsername.Text.Trim & "'"
		Call ExecuteReader(gconUser, reader, Sql)


		If reader.HasRows Then
			If CStr(reader("PASSWORD")) = CStr(txtPassword.Text) Then
				If OpManager.Checked Then
					If UCase(reader("USERROLE")) = "MANAGER" Then
						MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						fmMDI.Show()
						Me.Close()
					Else
						MessageBox.Show("You are not authorized to login as Manager", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						txtUsername.Focus()
						GoTo quit
					End If
				Else
					MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
					fmCashier.Show()
					fmCashier.BtnUser.Text = txtUsername.Text
					Me.Close()
				End If
			Else
				MessageBox.Show("Invalid Password,Please try again", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
				txtPassword.Clear()
				txtPassword.Focus()
				reader.Close()
			End If
		Else
			MessageBox.Show("No such user in system, Please contact the administrator", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Clear()
			txtPassword.Clear()
			txtUsername.Focus()
		End If
quit:
		reader.Close()
	End Sub

End Class



any help from all of you will be great!! :^: :P

This post has been edited by rob2y_k: 19 November 2009 - 03:45 AM


Is This A Good Question/Topic? 0
  • +

Replies To: any idea on how to do the extreme login?

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: any idea on how to do the extreme login?

Posted 19 November 2009 - 04:18 AM

hi dude :)
it is simple add a public variable in your login and see if it gets bigger then 3. something like that :

Public Class frmLogin
	Private cntTrys As Int16
	Private Sub CmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCancel.Click
		Dim hasil As MsgBoxResult

		hasil = MessageBox.Show("Are you sure want to exit from this system ?", "Exit system", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
		If hasil = MsgBoxResult.Yes Then
			End
		Else
			txtUsername.Focus()
		End If
	End Sub

	Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		txtUsername.Clear()
		txtPassword.Clear()
		txtUsername.Focus()
	End Sub

	Private Sub txtUsername_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUsername.KeyPress
		If Asc(e.KeyChar) = 13 Then
			txtUsername.Focus()
		End If
	End Sub


	Private Sub txtPassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassword.KeyPress
		If Asc(e.KeyChar) = 13 Then
			CmdOk.PerformClick()
		End If
	End Sub

	Private Sub CmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdOk.Click
		Dim fmCashier As New frmCashier
		Dim fmMDI As New frmMDI
		Dim Sql$
		Dim strs As String = ""
		Dim pwd As String = ""

		Dim com As New SqlClient.SqlCommand
		Dim reader As SqlClient.SqlDataReader = Nothing

		If txtUsername.Text.Trim = "" Then
			MessageBox.Show("Please enter the Username", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Focus()
			Exit Sub
		End If

		If txtPassword.Text.Trim = "" Then
			Call MessageBox.Show("Please enter the Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtPassword.Focus()
			Exit Sub
		End If

		Sql = "SELECT * FROM " & TBLUSERNAME
		Sql = Sql & " WHERE USERNAME='" & txtUsername.Text.Trim & "'"
		Call ExecuteReader(gconUser, reader, Sql)


		If reader.HasRows Then
			If CStr(reader("PASSWORD")) = CStr(txtPassword.Text) Then
				If OpManager.Checked Then
					If UCase(reader("USERROLE")) = "MANAGER" Then
						MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						fmMDI.Show()
						Me.Close()
					Else
						MessageBox.Show("You are not authorized to login as Manager", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						txtUsername.Focus()
						GoTo quit
					End If
				Else
					MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
					fmCashier.Show()
					fmCashier.BtnUser.Text = txtUsername.Text
					Me.Close()
				End If
			Else
				MessageBox.Show("Invalid Password,Please try again", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
				txtPassword.Clear()
				txtPassword.Focus()
				reader.Close()
				cntTrys = +1
			End If
		Else
			MessageBox.Show("No such user in system, Please contact the administrator", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Clear()
			txtPassword.Clear()
			txtUsername.Focus()
			cntTrys = +1
		End If
		If cntTrys > 3 Then End
quit:
		reader.Close()
	End Sub



good luck :)

This post has been edited by NoBrain: 19 November 2009 - 04:18 AM

Was This Post Helpful? 0
  • +
  • -

#3 theunborncoder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 123
  • Joined: 15-October 09

Re: any idea on how to do the extreme login?

Posted 19 November 2009 - 05:26 AM

You can use different tech to improve your login process
1. use counter variable and allow user upto 3 try
2. if 3 times wrong then block everything for 1 min using timer like windows
3. U can also ues registry to store ur password and login name hence no need of database. (google this topic)
- U can remember 3 false try using registry hence next time when valid user logged in show him summary about false tries.
Was This Post Helpful? 0
  • +
  • -

#4 rob2y_k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-November 09

Re: any idea on how to do the extreme login?

Posted 19 November 2009 - 05:48 AM

View PostNoBrain, on 19 Nov, 2009 - 03:18 AM, said:

hi dude :)
it is simple add a public variable in your login and see if it gets bigger then 3. something like that :

Public Class frmLogin
	Private cntTrys As Int16
	Private Sub CmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCancel.Click
		Dim hasil As MsgBoxResult

		hasil = MessageBox.Show("Are you sure want to exit from this system ?", "Exit system", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
		If hasil = MsgBoxResult.Yes Then
			End
		Else
			txtUsername.Focus()
		End If
	End Sub

	Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		txtUsername.Clear()
		txtPassword.Clear()
		txtUsername.Focus()
	End Sub

	Private Sub txtUsername_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUsername.KeyPress
		If Asc(e.KeyChar) = 13 Then
			txtUsername.Focus()
		End If
	End Sub


	Private Sub txtPassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassword.KeyPress
		If Asc(e.KeyChar) = 13 Then
			CmdOk.PerformClick()
		End If
	End Sub

	Private Sub CmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdOk.Click
		Dim fmCashier As New frmCashier
		Dim fmMDI As New frmMDI
		Dim Sql$
		Dim strs As String = ""
		Dim pwd As String = ""

		Dim com As New SqlClient.SqlCommand
		Dim reader As SqlClient.SqlDataReader = Nothing

		If txtUsername.Text.Trim = "" Then
			MessageBox.Show("Please enter the Username", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Focus()
			Exit Sub
		End If

		If txtPassword.Text.Trim = "" Then
			Call MessageBox.Show("Please enter the Password", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtPassword.Focus()
			Exit Sub
		End If

		Sql = "SELECT * FROM " & TBLUSERNAME
		Sql = Sql & " WHERE USERNAME='" & txtUsername.Text.Trim & "'"
		Call ExecuteReader(gconUser, reader, Sql)


		If reader.HasRows Then
			If CStr(reader("PASSWORD")) = CStr(txtPassword.Text) Then
				If OpManager.Checked Then
					If UCase(reader("USERROLE")) = "MANAGER" Then
						MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						fmMDI.Show()
						Me.Close()
					Else
						MessageBox.Show("You are not authorized to login as Manager", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
						txtUsername.Focus()
						GoTo quit
					End If
				Else
					MessageBox.Show(UCase(strs) & " Welcome to the System", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
					fmCashier.Show()
					fmCashier.BtnUser.Text = txtUsername.Text
					Me.Close()
				End If
			Else
				MessageBox.Show("Invalid Password,Please try again", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
				txtPassword.Clear()
				txtPassword.Focus()
				reader.Close()
				cntTrys = +1
			End If
		Else
			MessageBox.Show("No such user in system, Please contact the administrator", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
			txtUsername.Clear()
			txtPassword.Clear()
			txtUsername.Focus()
			cntTrys = +1
		End If
		If cntTrys > 3 Then End
quit:
		reader.Close()
	End Sub



good luck :)


wow..thanks a lot dude!! it was a great help...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1