// button signup private void buttonCreateAccount_Click() { // add a new user DataTable table = new DataTable(); DB db = new DB(); if (db.openConnection() == false) { Application.Current.MainPage.DisplayAlert("Server Error", "Try Again Later", "Ok"); } else { db.closeConnection(); String fname = firstName; //check sql MySqlCommand command = new MySqlCommand("INSERT INTO user(fname,lname,phone,email,password,title,userID) VALUES (@fn, @ln, @ph, @email, @pass, 'Member',@userID)", db.getConnection()); MySqlDataAdapter adapter = new MySqlDataAdapter(); command.Parameters.Add("@fn", MySqlDbType.VarChar).Value = firstName; command.Parameters.Add("@ln", MySqlDbType.VarChar).Value = lastName; command.Parameters.Add("@ph", MySqlDbType.VarChar).Value = PhoneNum; command.Parameters.Add("@email", MySqlDbType.VarChar).Value = Email; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = Password; command.Parameters.Add("@userID", MySqlDbType.VarChar).Value = Guid.NewGuid().ToString(); MySqlCommand command2 = new MySqlCommand("SELECT * FROM user WHERE email = @email2 and password = @pass2", db.getConnection()); command2.Parameters.Add("@email2", MySqlDbType.VarChar).Value = Email; command2.Parameters.Add("@pass2", MySqlDbType.VarChar).Value = Password; // open the connection db.openConnection(); adapter.SelectCommand = command2; adapter.Fill(table); int y = table.Rows.Count; //Console.WriteLine(String.IsNullOrEmpty(firstName)); //password.Text.Equals(passwordConfirm.Text) && phoneNum.Text.ValidatePhoneNumber(true) && emailaddress.Text.IsValidEmail() && password.Text.IsValidPassword() // check if the textboxes contains the default values if (checkTextBoxesValues() == true && y == 0) { // check if the password equal the confirm password if (Password.Equals(PasswordConfirm) && PhoneNum.ValidatePhoneNumber(true) && Email.IsValidEmail() && Password.IsValidPassword()) { // execute the query if (command.ExecuteNonQuery() == 1) { Application.Current.MainPage.DisplayAlert("Your Account Has Been Created", "Account Created", "Ok"); Navigation.PopModalAsync(); } else { Application.Current.MainPage.DisplayAlert("ERROR", "Account Failed to Create", "Ok"); } } else { if (Password.Equals(PasswordConfirm) == false) { Application.Current.MainPage.DisplayAlert("Confirm password doesnt match", "Password Error", "Ok"); } else if (PhoneNum.ValidatePhoneNumber(true) == false) { Application.Current.MainPage.DisplayAlert("Invalid phone number", "phone Number Error", "Ok"); } else if (Email.IsValidEmail() == false) { Application.Current.MainPage.DisplayAlert("Invalid Email", "Email", "Ok"); } else { Application.Current.MainPage.DisplayAlert("Password must contain between 8-16 characters", "Password error", "Ok"); } } } else { Application.Current.MainPage.DisplayAlert("Enter Your Information First Or Email Already Used", "Error", "Ok"); } // close the connection db.closeConnection(); } db.closeConnection(); }