Skip to content

Instantly share code, notes, and snippets.

Created September 10, 2011 06:42
Show Gist options
  • Save anonymous/1208029 to your computer and use it in GitHub Desktop.
Save anonymous/1208029 to your computer and use it in GitHub Desktop.
public function actionRegistr()
{
$model = new RegistrForm;
if (!Yii::app()->user->isGuest) {
throw new CException('Вы уже зарегистрированны!');
} else {
if (isset($_POST['RegistrForm'])) {
$model->attributes = $_POST['RegistrForm'];
$model->verifyCode = $_POST['RegistrForm']['verifyCode'];
if($model->validate()) {
if ($model->model()->count('username = :username', array($username))) {
// Указанный логин уже занят. Создаем ошибку и передаем в форму
$form->addError('login', 'Логин уже занят');
$this->render('registr', array('model' => $model));
} else {
// Выводим страницу что "все окей"
$model->save();
$this->render('registr_ok');
}
} else {
$this->render('registr', array('model' => $model));
}
} else {
$this->render('registr', array('model' => $model));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment