2
Reply

Log in probelm

Khoi

Khoi

Nov 15 2009 11:26 AM
2.8k
I want to create a log in form. Any user just inputs a user name "sa" and a password "callcenter", the program will pop up a window says Welcome, otherwise it says "Wrong password". But my code got an error as "Use of unassigned local variable 'input'". Please advise

    int input;
            string LoginName, Pass;
            LoginName = txtUserName.Text;
            Pass = txtPassword.Text;
            input = input + 1;
            if ((LoginName == "sa") && (Pass == "callcenter"))
            {
                lblMessage.Visible = true;
                lblMessage.Text = "Welcome";
            }
            else
                if (input < 3)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = "Wrong Pass. Try again";
                    txtUserName.Focus();
                }
                else
                {
                    MessageBox.Show("Unauthorized access,aborted");
                    Close();
                }

Answers (2)