Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Variables required
- string username = "'"+textBox1.Text+"'";
- string password = "'"+textBox2.Text+"'";
- string connStr = "server=localhost;user=root;database=game;port=3306;password=*****;";
- // Check if textboxes are filled in
- if (textBox1.Text == "")
- {
- MessageBox.Show("You did not fill in your username!");
- return;
- }
- if (textBox2.Text == "")
- {
- MessageBox.Show("You did not fill in your password!");
- return;
- }
- // Login to database
- MySqlConnection conn = new MySqlConnection(connStr);
- Thread.Sleep(1000);
- // Login
- try
- {
- conn.Open();
- label1.Text = "Connection established!";
- string get_info = "SELECT * FROM accounts WHERE account_name=" + username + " AND password_hash=" + password + "";
- MySqlCommand cmd = new MySqlCommand(get_info, conn);
- MySqlDataReader rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- string account_name = Convert.ToString(rdr["account_name"]);
- string password_hash = Convert.ToString(rdr["password_hash"]);
- string date = Convert.ToString(rdr["date"]);
- string email = Convert.ToString(rdr["email"]);
- string locked = Convert.ToString(rdr["locked"]);
- string verified = Convert.ToString(rdr["verified"]);
- string verikey = Convert.ToString(rdr["verikey"]);
- textBox3.Text = account_name;
- textBox4.Text = password_hash;
- textBox5.Text = date;
- textBox6.Text = email;
- if (locked == "0")
- {
- textBox7.Text = "No";
- }
- else
- {
- textBox7.Text = "Yes";
- }
- textBox8.Text = verikey;
- }
- rdr.Close();
- conn.Close();
- }
- catch (Exception ex)
- {
- label1.Text = ex.ToString();
- }
Add Comment
Please, Sign In to add comment