Answer the question
In order to leave comments, you need to log in
Why is the registration on the site not going through?
Hello, after registration, it redirects to a page with the "Page not found" error, I don’t understand why this happened ... Registration is enabled on all pages, that is, all controllers have the same code .. I can’t register on more than one page ...
SignupController.php
<?php
class SignupController extends Controller
{
public function actions()
{
return array(
'captcha'=>array(
'class' => 'CaptchaAction',
)
);
}
public function actionIndex()
{
$form = new User(User::SCENARIO_SIGNUP);
if (isset($_POST['User']) && $_POST['action'] == User::SCENARIO_SIGNUP)
{
$form->attributes = $_POST['User'];
if ($form->validate())
{
$transaction = Yii::app()->db->beginTransaction();
try
{
$form->create();
$transaction->commit();
// send register info
$user = User::model()->findByAttributes(array('email' => $form->email));
$user->sendRegisterInfo();
Yii::app()->user->setFlash('success', 'Вы успешно зарегистрировались. На указанный E-mail было отправлено письмо с паролем для входа.');
}
catch (Exception $e)
{
$transaction->rollback();
Yii::app()->user->setFlash('error', Yii::t('main', 'unknown_error'));
}
}
}
$this->render('index', array(
'form'=>$form
));
}
}
<?php echo CHtml::beginForm(); ?>
<div class="row">
<div class="col-12">
<div class="form-group" style="color: red;">
<p><?php $this->widget('FlashMessagesWidget'); ?>
<?php echo DHtml::errorSummary($form, '', array('style'=>'color: red;')); ?></p>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<?php echo CHtml::activeTextField($form, 'username', array('class'=>'form-control mb-30', 'placeholder'=>'Введите логин')); ?>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<?php echo CHtml::activeTextField($form, 'email', array('class'=>'form-control mb-30', 'placeholder'=>'Введите email')); ?>
</div>
</div>
<div class="contact-heading mb-50" style="color: red; text-align: center; margin: 0 auto; width: 100%;">
<p>
<?php if ($form->hasRefererCookie()) { ?>
<?php $refererUsername = $form->refererUsernameFromCookie(); ?>
<?php echo CHtml::activeHiddenField($form, 'inviterUsername', array('value' => $refererUsername)); ?>
</p>
</div>
<div class="col-12">
<div class="form-group">
<input type="text" class="form-control mb-30" value="Вас пригласил: <?php echo $refererUsername; ?>" readonly style="width: 100%;">
</div>
</div>
<?php } ?>
<div class="col-12">
<div class="form-group form-control mb-30" style="text-align: center; height: 62px; cursor: pointer;">
<img <?php $this->widget('CCaptcha'); ?>
</div>
</div>
<div class="col-12">
<div class="form-group">
<?php echo CHtml::activeTextField($form, 'verifyCode', array('placeholder'=>$form->getAttributeLabel('enterVerifyCode'), 'class'=>'form-control mb-30')); ?>
</div>
</div>
<div class="col-12">
<?php echo CHtml::hiddenField('action', User::SCENARIO_SIGNUP); ?>
<button class="btn uza-btn btn-3 mt-15" style="width: 100%;">Зарегистрироваться</button>
</div>
</div>
<?php echo CHtml::endForm(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question