Created
September 10, 2011 06:42
-
-
Save anonymous/1208029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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