private void button1_Click(object sender, EventArgs e)
        {
            try
               {

            string MyConnection = "datasource=localhost;port=3306;username=root;password=root";

            string Query = "insert into database.users(Username, Password, Name, Email) values('" + this.textBox2.Text + "','" + this.textBox3.Text + "', '" + this.textBox1.Text + "','" + this.textBox4.Text + "')";

            MySqlConnection MyConn = new MySqlConnection(MyConnection);

            MySqlCommand MyCommand = new MySqlCommand(Query, MyConn);
            MySqlDataReader MyReader;
            MyConn.Open();
            MyReader = MyCommand.ExecuteReader();
              MessageBox.Show("Registered successfully");
            this.Hide();
            MyReader.Close();
            MySqlDataReader MyReader2;

            string query2 = "Select * from database.users where Username='******'and Password='******';";
            MySqlCommand MyCommand2 = new MySqlCommand(query2, MyConn);
                   MyReader2 = MyCommand2.ExecuteReader();
                   int count = 0;
            while (MyReader2.Read())
            {
                count = count + 1;
            }
                if (count==1)
                {

                    MainForm m=new MainForm(MyReader2.GetString("Name"));
                    m.Show();

                }

            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.Message);
              }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string MyConnection = "datasource=localhost;port=3306;username=root;password=root";
            MySqlConnection conn = new MySqlConnection(MyConnection);
            MySqlDataAdapter da = new MySqlDataAdapter("Select * from database.users where Username='******'and Password='******'", conn);
            DataTable dt = new System.Data.DataTable();
            da.Fill(dt);
            if (dt.Rows.Count == 1)
            {
                this.Hide();
                MainForm m = new MainForm(dt.Rows[0][0].ToString());
                m.Show();
                ((Form)m).Controls["label5"].Text = dt.Rows[0][0].ToString();
            }
            else
            {
                MessageBox.Show("Check Username/password and Please Try again");
                textBox2.Clear();
                textBox1.Clear();

            }
        }