throw new Exception(I18n::t('register.err.nicknamenotvalid')); } // check if nickname length is ok if (!preg_match('/^\\w{3,20}$/', $nickname)) { throw new Exception(I18n::t('register.err.nicknamelength')); } // check if nickname is unique if (User::nicknameIsRegistered($nickname)) { throw new Exception(I18n::t('register.err.nicknameexists')); } // check if e-mail address is valid if (!preg_match("/^\\S+@\\S+\\.\\S+\$/", $email)) { throw new Exception(I18n::t('register.err.emailnotvalid')); } // check if e-mail is unique if (User::emailIsRegistered($email)) { throw new Exception(I18n::t('register.err.emailexists')); } } catch (Exception $e) { $errorMessage = $e->getMessage(); } // validation is successful if (!isset($errorMessage)) { $displayForm = false; // perform the actual user registration (store user to DB) $user = User::createUser($nickname, $email, $pw); if ($user == false) { $message = I18n::t('register.err.notcreated'); } else { $message = I18n::t('register.success'); }