I have a problem with my code. I want to make a login system C# with no repetitive accounts. Can anyone help me do so? Help would be greatly appreciated!
private void enterButton_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand da = new SqlCommand("SELECT * FROM RegTable", con);
SqlDataReader reader = null;
reader = da.ExecuteReader();
while (reader.Read())
{
if (usernameTextBox.Text == (reader["Username"].ToString()) && PasswordtextBox.Text == (reader["Password"].ToString()))
{
MessageBox.Show("Welcome!");
canForm x = new canForm();
x.ShowDialog();
this.Hide();
con.Close();
}
else
{
MessageBox.Show("Account Doesn't Exist");
}
}
}
You are makeing your own
Membershipsytem, so you should createSessionstable, and then store your Session informations like:LoggedUser, TimeLoggedOn. In each logOn you should then check if that user is already logged in.Things to consider: session expiration (when user closes browser without loggingOut).