Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool tryLogin(string username, string password)
- {
- MySqlConnection con = new MySqlConnection("host=hostremoved;user=user_removed;password=passwordremoved;database=databaseremoved;");
- MySqlCommand cmd = new MySqlCommand("SELECT * FROM login WHERE user_name = '" + username + "' AND user_pass = '" + password + "';");
- cmd.Connection = con;
- con.Open();
- MySqlDataReader reader = cmd.ExecuteReader();
- if (reader.Read() != false)
- {
- if (reader.IsDBNull(0) == true)
- {
- cmd.Connection.Close();
- reader.Dispose();
- cmd.Dispose();
- return false;
- }
- else
- {
- cmd.Connection.Close();
- reader.Dispose();
- cmd.Dispose();
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- private void btnlogin_Click(object sender, EventArgs e)
- {
- if (tryLogin(txtuser.Text, txtpass.Text) == true)
- {
- MessageBox.Show("Login worked!");
- }
- else
- {
- MessageBox.Show("Login failed!");
- GRANT ALL ON yourDbName.* TO 'yourUser'@'yourIP' IDENTIFIED BY "yourPassword";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement