Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,326 Categories: 12

Total Tutorial Views: 41,306,780

How To Make A Simple Login System C#

Tutorial Name: How To Make A Simple Login System C#  

Category: PC Tutorials

Submitted By: Nissan

Date Added:

Comments: 3

Views: 6,439

Related Forum: PC Building Forum

Share:

Hi today i am making a tutorial on : How To Make A Simple Login System C#.

We are going to start off by making a form and adding the following items from the tool box to your form :

2 text boxes
1 button.

Once you have them double click on your button to get the event handler.

Now you will see some code and it will look like this :

[ Register or Signin to view external links. ]

Now go above the button handler and type the following :

internal void Login()
      {
         // this checks textbox 1 and textbox 2 are the correct login length for user name and password
         if((textBox1.Text.Length <= 4) || (textBox2.Text.Length <=4))
         {
            //Tells the user that the user name or password is not the correct length
            MessageBox.Show("Username or password is not the correct length","Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         //this is the username and password
         if((textBox1.Text == "Admin")&& (textBox2.Text == "AdminPassword"))
         {
            //tells the user that there login details are correct
            MessageBox.Show("Login information correct!")
         }
         else
         {
            //tells the user that there login details are not correct
            MessageBox.Show("Incorrect Login Details\n Please try again")
         }
      }


So now your code will look like :
[ Register or Signin to view external links. ]

Now as you can see we have not done anything on the button yet so lets do that now.

In the button Event Handler we are going to use a try catch block and that code is :


try{ Login();}
catch(Exeption) { }


Now if you followed this tutorial correct your code will look like this :

[ Register or Signin to view external links. ]

Nope you learned something from this little simple tutorial .

Ratings

Current rating: 3.79 by 52 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"How To Make A Simple Login System C#" :: Login/Create an Account :: 3 comments

If you would like to post a comment please signin to your account or register for an account.

NissanPosted:

Valor great tutorial it helped me out a lot


Thanks for the feedback I hope it helped you.

ValorPosted:

great tutorial it helped me out a lot

IntPosted:

Very nice tutorial mate, I know C# myself too.