protected void btnCreateNewAccount_Click(object sender, EventArgs e) //New User { if (txtDesiredUsername.Text == "") //CHECKS FOR ANY BLANK FIELDS IN ACCOUNT CREATION { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (txtName.Text == "") { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (txtEmail.Text == "") { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (txtPhone.Text == "") { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (txtDesiredPassword.Text == "") { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (txtDesiredPasswordConfirm.Text == "") { lblErrorMessage.Text = "Please make sure all fields are filled out correctly."; return; } if (ddlRep.Text == "") { lblErrorMessage.Text = "Please select which account type you are making."; return; } if (txtDesiredPassword.Text != txtDesiredPasswordConfirm.Text) //Checks to make sure the two passwords match { lblErrorMessage.Text = "Your passwords do not match."; return; } UserFunctions uf = new UserFunctions(); DBConnect objDB = new DBConnect(); string desiredname = txtDesiredUsername.Text; string sqlCheck = "SELECT * From User_t WHERE Username = '******'"; DataSet myDS = objDB.GetDataSet(sqlCheck); //String checking = myDS.Tables[0].Rows[0][0]; if (myDS.Tables[0].Rows.Count > 0) { lblErrorMessage.Text = "Username is already taken. Please select another."; } else //if all fields ok make a new account and redirect to homepage { string name = txtName.Text; string phone = txtPhone.Text; string email = txtEmail.Text; string username = txtDesiredUsername.Text; string password = txtDesiredPassword.Text; string accounttype = ddlRep.Text; UserObject newUser = new UserObject(name, phone, email, username, password, accounttype); uf.AddNewUserDB(name, phone, email, username, password, accounttype); //Adds record to the User_t Database Session["User"] = newUser; Response.Redirect("UserHome.aspx"); } }