Thread Contributor: Blessings
Programming with Blessings! C# | Episode 1 | Advanced Login
#1
Hello and welcome to my C# Tutorial! Today I am going to be showing you how to make an advanced login system using Visual Studio 2013. 
(Other versions are still compatible with this code.)

Here is the previous code that we had and now we are adding on...
[spoiler]
First: We are going to add one button and two text boxes.
[spoiler]Screenshot by Lightshot[/spoiler]



Next: I am going to right click the first textbox, scroll down to design and set its name as Username. Same with the second text box but with the design name password.
[spoiler]Screenshot by Lightshot[/spoiler]



Finally: Double the click the button and enter the following code.
[spoiler]Screenshot by Lightshot[/spoiler]



Basically what this code does is...
if (theCurrentTextInUsernameTextBox is EQUAL to "yourUsername" then show a message box saying success but...
if (theCurrentTextInUsernameTextBox is NOTEQUAL to (!=) "yourUsername" then show a message box saying failure...
[/spoiler]

------------------------------------------------------------------------------------------------------------







Now hit Ctrl+Alt+L to open Solution Explorer and right click on the name of your project.
[spoiler]Screenshot by Lightshot[/spoiler]



Now this is going to be the registration form!
So we are going to add 2 more textboxes and a button, now double click on the button!
[spoiler]Screenshot by Lightshot[/spoiler]



Be sure to change the name of your textboxes under the design section userRegister and passRegister (you can use anything)
[spoiler]http://prntscr.com/9o00vu[/spoiler]



Now for the code of the button we are going to have it save your username and password in your Visual Studio settings...
First, go to [spoiler]http://prntscr.com/9o01kz[/spoiler] 



Then navigate to Settings and add the following:
[spoiler]http://prntscr.com/9o063m[/spoiler]



Now go back to the register button code and add this:
[spoiler]http://prntscr.com/9o05n6[/spoiler]



Now hit Ctrl+Alt+L again and double click on Program.cs and change the new Form1 to new Form2 (ONLY WHAT I CHANGE)
[spoiler]http://prntscr.com/9o083k[/spoiler]



Now go to your form1 form and double click the form and add this:
[spoiler]http://prntscr.com/9o06t7[/spoiler] //this hides the form off the bat..



Then go to the button code and change it to this: //What this does is it checks if the saved string under the Properties.Settings.Default.userNameText is equal to
[spoiler]http://prntscr.com/9o0757[/spoiler]       //what the text is in the textbox and if so then do whatever....



Almost done, don't worry.. Next double click the register button and add this line of code:
[spoiler]http://prntscr.com/9o0ati[/spoiler]



Then double click the form2 and add this:
[spoiler]http://prntscr.com/9o09y5[/spoiler] but declare [spoiler]http://prntscr.com/9o0acp[/spoiler]



Finally add a button on Form1 login form and put the text as "Reset Account" and put the following code:
[spoiler]http://prntscr.com/9o0bxr[/spoiler]



Done! So now if you click the reset account button, it won't automatically go to the login it will request you to register first..

TIP: If you want to have your form really look like a login form, right click the password text box, scroll down to PassChar and put * or anything you want!
[spoiler]http://prntscr.com/9o0cvr[/spoiler]



Thanks for reading and I hope you have learned something from this lesson!

#2
For which browsers? Any of them? I'm using Firefox at the moment, is it compatible with your code, @Blessings?

#3
(06-12-2016, 03:59 PM)Naiwen Wrote: For which browsers? Any of them? I'm using Firefox at the moment, is it compatible with your code, @Blessings?

It wouldn't be used with a browser. 

OT: great tutorial @Blessings - thanks for sharing it with us!
"I'm a gamer, not because I don't have a life... But because I choose to have many"

#4
(06-12-2016, 03:59 PM)Naiwen Wrote: For which browsers? Any of them? I'm using Firefox at the moment, is it compatible with your code, @Blessings?

It's a browser on the application, does not conflict with the current browser you are using right now. It has it's own built-in.

(06-12-2016, 05:40 PM)katos Wrote:
(06-12-2016, 03:59 PM)Naiwen Wrote: For which browsers? Any of them? I'm using Firefox at the moment, is it compatible with your code, @Blessings?

It wouldn't be used with a browser. 

OT: great tutorial @Blessings - thanks for sharing it with us!

Glad I could help!



Users browsing this thread: 1 Guest(s)