I have problem with my login system here.
I can go to next form when I input the valid username and password.
And when I input wrong username and correct password, still I can go to next form.
And correct username and wrong password I can still go to next form.
What is the correct code for not letting go to next from if my username or password is wrong?
Here’s my code.
private void btnEnter_Click(object sender, EventArgs e)
{
if (tbUsername.Text == "username")
{
AdminMainMenu x = new AdminMainMenu();
x.Show();
t.Play();
this.Dispose();
}
else
{
SystemSounds.Hand.Play();
MessageBox.Show("Invalid Username! ", "Error");
}
if (tbPassword.Text == "password")
{
AdminMainMenu x = new AdminMainMenu();
x.Show();
t.Play();
this.Dispose();
}
else
{
SystemSounds.Hand.Play();
MessageBox.Show("Invalid Password! ", "Error");
}
}
I can only hazard a guess at what you are asking, but if you want the username and password to both be correct before showing the form use this instead