void SubmitButton_Click(object sender, EventArgs e) { if (UsernameTextbox.Text == "" || PasswordTextbox.Text == "" || ConfirmedPasswordTextbox.Text == "") { StatusLiteral.Text = "Please complete all of the fields"; } else if (PasswordTextbox.Text != ConfirmedPasswordTextbox.Text) { StatusLiteral.Text = "Passwords do not match"; } else { string username = UsernameTextbox.Text; string password = PasswordTextbox.Text; string hashedPassword; Database db = new Database(); db.Connect(); if (db.UserExists(username)) { StatusLiteral.Text = "Username already exists"; db.Close(); } else { hashedPassword = MD5Util.EncodePassword(password); db.AddUser(username, hashedPassword); db.Close(); Session["username"] = username; Response.Redirect("SuccessPage.aspx?successCode=signUp"); } } }
void SubmitButton_Click(object sender, EventArgs e) { if (UsernameTextBox.Text == "" || PasswordTextBox.Text == "") { StatusLiteral.Text = "Please complete all of the fields"; } else { string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; string hashedPassword = MD5Util.EncodePassword(password); Database db = new Database(); db.Connect(); if (db.UserExists(username) == false) { StatusLiteral.Text = "Username does not exist"; } else { //check password if (db.PasswordsMatch(username, hashedPassword)) { db.Close(); Session["username"] = username; string redirectPath = getRedirectPath(); Response.Redirect(redirectPath); } else { StatusLiteral.Text = "Incorrect password"; db.Close(); } } } }