Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

login attempts

$
0
0

im a newbie in asp.net  can someone please help me correct my code for this to work
im using vs community 2017 and ms access
can someone please help me

Imports System.Data.OleDb

Public Class Login
Inherits System.Web.UI.Page

Dim attempt As Integer = 1

Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Server.MapPath("dbase/Infinite.accdb"))
Dim dr As OleDbDataReader

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cn.Open()

Dim usn As New OleDbCommand

usn.CommandText = "SELECT * FROM Clients WHERE ((Username = '" & TextBox1.Text & "' OR EmailAdd = '" & TextBox1.Text & " ') AND Password = '" & TextBox2.Text & "' AND Verification = 'Yes')"
usn.Connection = cn

dr = usn.ExecuteReader

If dr.HasRows Then
Session("User") = TextBox1.Text
Response.Redirect("Main.aspx")
TextBox1.Text = ""
TextBox2.Text = ""

ElseIf attempt = 3 Then
Timer1.Enabled = True
TextBox1.Enabled = False
TextBox2.Enabled = False
Session("InvalidLog") = TextBox1.Text
Response.Write("<Script> alert('Maximum number of Failed Login(3), Your account is blocked for 3 Mins.')</script>")

Else
attempt = attempt + 1
TextBox1.Focus()
Response.Write("<Script> alert('Invalid Username or Password!')</script>")

End If

If TextBox1.Text = "lc" And TextBox2.Text = "sad" Then
Response.Redirect("Adm.aspx")
End If
End Sub

Protected Sub reg_Click(sender As Object, e As EventArgs) Handles reg.Click
Response.Redirect("Regist.aspx")
End Sub

Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Timer1.Enabled = True Then
Timer1.Interval = 10000
Timer1.Enabled = False
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox1.Focus()


End If
End Sub
End Class


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>