I'm create a new signup page successfully. whenever I enter a username and password and hit a submit button it save's the credentials but the problem here is two times entered that data.
private void sbmtbtn_Click(object sender, EventArgs e)
{
if (usrnmtxtbx.Text != "")
{
if (pswdtxtbx.Text != "")
{
if (cnfrmtxtbx.Text != "")
{
if (pswdtxtbx.Text == cnfrmtxtbx.Text)
{
MySqlConnection Con = new MySqlConnection(ConnectionString);
MySqlCommand Cmd;
Con.Open();
try
{
Cmd = Con.CreateCommand();
Cmd.CommandText = "INSERT IGNORE INTO signup(username, password,confirm) VALUES(@username,@password,@confirm)";
Cmd.Parameters.Add("@username", MySqlDbType.VarChar).Value = usrnmtxtbx.Text;
Cmd.Parameters.Add("@password", MySqlDbType.VarChar).Value = pswdtxtbx.Text;
Cmd.Parameters.Add("@confirm", MySqlDbType.VarChar).Value = cnfrmtxtbx.Text;
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = Cmd;
adapter.Fill(table);
Cmd.ExecuteNonQuery();
MessageBox.Show("Your Account resgistred Successfully", "information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception)
{
throw;
}
finally
{
Con.Close();
}
}
}
}
}
}
OutPut :
idsignup username password confirm
1 hello 123 123
2 hello 123 123