Click here to Skip to main content
15,884,936 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Is there a way to do multiple username and passwords with this?

C#
if ((textBox1.Text == "Quinn") && (textBox2.Text == "Qmanqtip12"))
{ 
  System.Threading.Thread.Sleep(4000); 
  MessageBox.Show("Welcome To AL7", "Login Succesfull", 
  MessageBoxButtons.OK, MessageBoxIcon.Information); 
  new Form2().Show(); 
  this.Hide(); 
} 
else 
{ 
  MessageBox.Show("Usename or Password Incorrect", "Error", 
  MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
} 


What I have tried:

Doing , and other "" and no work
Posted
Updated 27-Dec-16 2:17am
Comments
Dave Kreskowiak 17-Dec-16 16:09pm    
With that code? Not really. You'd have to scrap it and rewrite to support some kind of database of users, be it in a actual database engine or a list of accounts in a file of some kind.

You'd have to write code to retrieve and lookup any entered name in this database and then you could use a couple of parts of the code you have, basically, everything that isn't the if statement.
ZurdoDev 17-Dec-16 20:28pm    
What do you actually mean? As you can see the code has a hard-coded username and password in it.
Philippe Mori 17-Dec-16 22:56pm    
This make absolutely no sense at all. You never, never write code like that. It has security issues and it is not maintainable at all. And how the code would update itself when a user change his password or register himself. It would be a good idea to read tutorials on that. It should be easy to find information on the web.
[no name] 19-Dec-16 10:16am    
Do the users work on the same computer or access the program through a common network shared folder?

Let Windows do the authentication for you. Set the file access permission to only those users you wish to allow.

Quote:
Is there a way to do multiple username and passwords with this?
Even if you are not a developer, I think the code is still easy enough to read that this code only works with one username and password combination.

The comments have given you suggestions on how to fix it but since you have not replied I am posting this as solution since it does answer your question.
 
Share this answer
 
Use, in a loop, an array of (allowed) UserInfo objects, each of them having a username and a password fields.
 
Share this answer
 
Hi,

Try some database to store your users, nd let them only aalow to use your aplication. U be the admin who hav all rights .

And then create a generalize login system for all users. All to use your system only to auhtneticated ones for others popup the message .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900