This code defines a login form with username and password text boxes. It attempts to authenticate the user by hashing the password and querying the database to match the username, hashed password, and check if the account is unlocked. Depending on the query results, it either clears the text boxes and opens a new form, or displays an error message.
This code defines a login form with username and password text boxes. It attempts to authenticate the user by hashing the password and querying the database to match the username, hashed password, and check if the account is unlocked. Depending on the query results, it either clears the text boxes and opens a new form, or displays an error message.
This code defines a login form with username and password text boxes. It attempts to authenticate the user by hashing the password and querying the database to match the username, hashed password, and check if the account is unlocked. Depending on the query results, it either clears the text boxes and opens a new form, or displays an error message.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load con.Open(constr) cmd.ActiveConnection = con End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click Try cmd.CommandText = "select user_name from accounts" rs = cmd.Execute If Not rs.EOF Then cmd.CommandText = $"select user_name, lock from accounts where user_name = '{TextBox1.Text}' and lock = false" rs = cmd.Execute If Not rs.EOF Then HashedInputPassword = HashPassword(TextBox2.Text) cmd.CommandText = $"Select * from Accounts where User_name = '{TextBox1.Text}' And Pass_word = '{HashedInputPassword}'" rs = cmd.Execute If rs.EOF = False Then TextBox1.Clear() TextBox2.Clear() CRUD.Show() Me.Hide() ElseIf TextBox1.Text = "" Or TextBox2.Text = "" Then MessageBox.Show("Type your username or password") Else cmd.CommandText = $"Select * from Accounts where User_name = '{TextBox1.Text}'" rs = cmd.Execute If rs.EOF = False Then MessageBox.Show("Wrong password") Else MessageBox.Show("This account does not exist") End If End If Else MsgBox("Account is locked") End If Else MsgBox("Account does not exists") End If
Catch ex As Exception MessageBox.Show(ex.Message) End Try