private void SignUpButton_Click(object sender, EventArgs e) { string firstName = firstNameInput.Text; string lastName = lastNameInput.Text; string address = addressInput.Text; string phoneNumber = phoneNumberInput.Text; string mail = mailInput.Text; string pass = passwordInput.Text; if (firstName == "" || lastName == "" || address == "" || phoneNumber == "" || mail == "" || pass == "") { MessageBox.Show("Please fill in all informations."); return; } con2.Open(); try { string sql2 = "SELECT * FROM customer WHERE mailAddress = '" + mail + "' or phoneNumber = '" + phoneNumber + "'"; DataTable dt2 = new DataTable(); MySqlDataAdapter adapter2 = new MySqlDataAdapter(); MySqlCommand command2 = new MySqlCommand(); command2.CommandText = sql2; command2.Connection = con2; adapter2.SelectCommand = command2; adapter2.Fill(dt2); try { dt2.Rows[0]["ID"].ToString(); MessageBox.Show("Phone number or mail address used before."); return; } catch (Exception) { if (!string.IsNullOrWhiteSpace(mail)) { try { var eMailValidator = new System.Net.Mail.MailAddress(mail); } catch (FormatException) { MessageBox.Show("Invalid Mail Address."); return; } } else { MessageBox.Show("Please fill in all informations."); return; } if (!string.IsNullOrWhiteSpace(phoneNumber)) { if (!IsPhoneNumber(phoneNumber)) { MessageBox.Show("Invalid Phone Number."); return; } } else { MessageBox.Show("Please fill in all informations."); return; } if (!string.IsNullOrWhiteSpace(firstName) && !string.IsNullOrWhiteSpace(lastName) && !string.IsNullOrWhiteSpace(address) && !string.IsNullOrWhiteSpace(pass)) { string conn; MySqlConnectionStringBuilder build = new MySqlConnectionStringBuilder(); build.UserID = "root"; build.Password = "******"; build.Database = "orgamig"; build.Server = "localhost"; conn = build.ToString(); connection = new MySqlConnection(conn); string sql = "INSERT INTO customer(firstName,lastName,mailAddress,password,phoneNumber,address) " + "values('" + firstName + "','" + lastName + "','" + mail + "','" + sha256_hash(pass) + "','" + phoneNumber + "','" + address + "');"; MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); command.CommandText = sql; command.Connection = connection; adapter.SelectCommand = command; MySqlDataReader MyReader; connection.Open(); MyReader = command.ExecuteReader(); MessageBox.Show("Sign Up Successful. You can login now."); this.Close(); LoginScreen loginScreen = new LoginScreen(); loginScreen.Show(); } else { MessageBox.Show("Please fill in all informations."); return; } } } catch (Exception er) { MessageBox.Show(er.Message); } finally { con2.Close(); } }