Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection("Server=cl1-sql22.phpnet.org;Port=3306;database=yzi38822; User Id=yzi38822;Password=M0kTZX33pyO6;");

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                    textView3.Text = "Successfully connected";
                }
                else
                {
                    textView4.Text = "Connexion déjà établi";
                }
            }
            catch (MySqlException ex)
            {
                textView3.Text = ex.ToString();
            }

            string query = "SELECT user,password FROM members WHERE user = '******' and password = '******'";

            MySqlDataReader reader = new MySqlCommand(query, con).ExecuteReader();

            if (reader.Read())
            {
                textView5.Text = (reader["user"].ToString());
                textView6.Text = (reader["password"].ToString());
                reader.Close();
                session.createUserLoginSession(textView5.Text, textView6.Text);
                Intent i = new Intent(Application.Context, typeof(Profil));
                i.AddFlags(ActivityFlags.ClearTop);
                i.SetFlags(ActivityFlags.NewTask);
                StartActivity(i);
            }
            else
            {
                textView5.Text = "Aucun compte existant !";
                reader.Close();
            }
            reader.Close();
        }