Post: [C#] How to make a Login Panel
11-10-2014, 12:45 PM #1
Swaqq
Professional Thanker
(adsbygoogle = window.adsbygoogle || []).push({}); yo guys this is a quick tutorial on how to make a login form in C#. This will require website hosting. I recommend x10Hosting.

1: Make a new solution in C# Called anything you want.

2: At the top of your solution, add "using System.Net;"
You must login or register to view this content.

3: Make a form design that looks something like this:
You must login or register to view this content.

4: Go to your textbox2(or the textbox you are using for your password) properties and change the PasswordChar to "●"
You must login or register to view this content.

5: Double click on the login button and insert the following above the button code.
    

public string MemberListLink = "https://swaqqdemologin.x10host.com/LoginInfo/";
public string str;

public void Login(string username, string password)
{

if (username == "" && password == "")
{
MessageBox.Show("Please enter your Username and Password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (username == "")
{
MessageBox.Show("Please Enter your username", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (password == "")
{
MessageBox.Show("Please Enter your password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
WebClient MemString = new WebClient();
try { str = MemString.DownloadString(MemberListLink); }
catch { MessageBox.Show("Error Connecting to Server"); }
if (str.Contains(username + "+" + password))
MessageBox.Show("Logged In", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
else MessageBox.Show("Wrong username or Password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}


In the end it should look like:
You must login or register to view this content.

Change my link to your hosting.

6: On your Login button code, write the following
You must login or register to view this content.
Textbox1 and 2 are username and pass, you can change them to the name of your textboxes.

7: Go to your file manager on your hosting and make a new file like so:
You must login or register to view this content.

Then you will make your username and password to the following:
You must login or register to view this content.

Then press here:
You must login or register to view this content.

If you have done everything correctly, you should be able to launch the app and login:
You must login or register to view this content.

Thanks for reading :3 BTW I'm still making a sign up so yea.

-Cya

The following 12 users say thank you to Swaqq for this useful post:

Boliberrys, Father Luckeyy, iRnZ, Norway-_-1999, PhucedMODZ, Pichu, RTE, Kronos, Smooth, Laser, xDebugKiller, ZerthekModz

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo