Guest User

Untitled

a guest
Jul 22nd, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. // Variables required
  2. string username = "'"+textBox1.Text+"'";
  3. string password = "'"+textBox2.Text+"'";
  4. string connStr = "server=localhost;user=root;database=game;port=3306;password=*****;";
  5.  
  6. // Check if textboxes are filled in
  7. if (textBox1.Text == "")
  8. {
  9. MessageBox.Show("You did not fill in your username!");
  10. return;
  11. }
  12. if (textBox2.Text == "")
  13. {
  14. MessageBox.Show("You did not fill in your password!");
  15. return;
  16. }
  17.  
  18. // Login to database
  19. MySqlConnection conn = new MySqlConnection(connStr);
  20. Thread.Sleep(1000);
  21. // Login
  22. try
  23. {
  24. conn.Open();
  25. label1.Text = "Connection established!";
  26. string get_info = "SELECT * FROM accounts WHERE account_name=" + username + " AND password_hash=" + password + "";
  27. MySqlCommand cmd = new MySqlCommand(get_info, conn);
  28. MySqlDataReader rdr = cmd.ExecuteReader();
  29.  
  30. while (rdr.Read())
  31. {
  32. string account_name = Convert.ToString(rdr["account_name"]);
  33. string password_hash = Convert.ToString(rdr["password_hash"]);
  34. string date = Convert.ToString(rdr["date"]);
  35. string email = Convert.ToString(rdr["email"]);
  36. string locked = Convert.ToString(rdr["locked"]);
  37. string verified = Convert.ToString(rdr["verified"]);
  38. string verikey = Convert.ToString(rdr["verikey"]);
  39.  
  40. textBox3.Text = account_name;
  41. textBox4.Text = password_hash;
  42. textBox5.Text = date;
  43. textBox6.Text = email;
  44. if (locked == "0")
  45. {
  46. textBox7.Text = "No";
  47. }
  48. else
  49. {
  50. textBox7.Text = "Yes";
  51. }
  52. textBox8.Text = verikey;
  53. }
  54. rdr.Close();
  55. conn.Close();
  56. }
  57. catch (Exception ex)
  58. {
  59. label1.Text = ex.ToString();
  60. }
Add Comment
Please, Sign In to add comment