示例#1
0
        /// <summary>
        /// Register the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // Get the data
            string firstname = txtVoornaam.Text;
            string lastname  = txtAchternaam.Text;
            string email     = txtEmail.Text;

            string passHash = Common.Hash(txtWachtwoord.Text, 10000);

            // Check if the email actually matches what we want an email to look like
            Match emailMatch = Regex.Match(txtEmail.Text, @".+[@].+[.].{2,6}", RegexOptions.IgnoreCase);

            // Check if the first- and lastname are not empty and the email matches a few things
            if (firstname != "" && lastname != "" && emailMatch.Success)
            {
                // Create the user using the data he/she filled in
                if (UserSQL.createNewUser(firstname, lastname, passHash, email))
                {
                    createERRPar.Attributes.CssStyle.Add("display", "block");
                    createERRPar.Attributes["class"] += " alert";
                    createERRPar.Attributes["class"] += " alert-success";
                    lblCreateERR.Text =
                        (Properties.Settings.Default.lang == "NL")
                        ? "Account was succesvol aangemaakt!"
                        : "Account was created succesfully";
                }
                else // Something went wrong
                {
                    createERRPar.Attributes.CssStyle.Add("display", "block");
                    createERRPar.Attributes["class"] += " alert";
                    createERRPar.Attributes["class"] += " alert-danger";
                    lblCreateERR.Text = (Properties.Settings.Default.lang == "NL")
                        ? "Er is iets misgegaan met het toevoegen van de gebruiker. Probeer het opnieuw?"
                        : "Something went wrong when creating the user. Please try again.";
                }
            }
            else // First- or lastname are not filled in or the way the email is constructed is not correct
            {
                createERRPar.Attributes.CssStyle.Add("display", "block");
                createERRPar.Attributes["class"] += " alert";
                createERRPar.Attributes["class"] += " alert-danger";
                lblCreateERR.Text = (Properties.Settings.Default.lang == "NL")
                    ? "De voor- of achternaam is niet ingevuld. Mogelijk is het email adres ook niet conform aan de eisen van een email adres."
                    : "The first or last name is not filled in. The email adress may also not be in the correct format.";
            }
        }