Hi! I'm currently doing sign up page where customer can sign up to use my website.
however, when they type username, they will prompt that username is taken ...
how to check in database if the username is already been taken??
i got 2 sign up page. 1st page is where the customer type their username, and password.
2nd page is where they type thier personal particulars and then it will store in database..
below are my codes fot my 1st page
protected void btnNext_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
{
return;
}
Session["username"] = tbNewId.Text;
Session["password"] = tbConfirmPassword.Text;
Response.Redirect("~/SignUp2.aspx");
}
this is my codes for second page
protected void btnNext_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
String sql = "Insert into Customer (Name, Phone, Email, Address, Username, Password) ";
sql = sql + "Values (@Name, @Phone, @Email, @Address, @Username, @Password)";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@Name", tbName.Text);
cmd.Parameters.AddWithValue("@Phone", tbPhone.Text);
cmd.Parameters.AddWithValue("@Email", tbEmail.Text);
cmd.Parameters.AddWithValue("@Address", tbAddress.Text);
cmd.Parameters.AddWithValue("@Username", Session["username"]);
cmd.Parameters.AddWithValue("@Password", Session["password"]);
// Insert into database table
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("~/Homepage.aspx");
}