Example #1
0
        //Construct a user object
        $user = new User($username, $displayname, $password, $email);
        //Checking this flag tells us whether there were any errors such as possible data duplication occured
        if (!$user->status) {
            if ($user->username_taken) {
                $errors[] = lang("ACCOUNT_USERNAME_IN_USE", array($username));
            }
            if ($user->displayname_taken) {
                $errors[] = lang("ACCOUNT_DISPLAYNAME_IN_USE", array($displayname));
            }
            if ($user->email_taken) {
                $errors[] = lang("ACCOUNT_EMAIL_IN_USE", array($email));
            }
        } else {
            //Attempt to add the user to the database, carry out finishing  tasks like emailing the user (if required)
            if (!$user->AddUserToDB()) {
                if ($user->mail_failure) {
                    $errors[] = lang("MAIL_ERROR");
                }
                if ($user->sql_failure) {
                    $errors[] = lang("SQL_ERROR");
                }
            }
        }
    }
    if (count($errors) == 0) {
        $successes[] = $user->success;
    }
}
require_once "models/header.php";
?>