I have a password-reset form within a yii-framework site. When the user submits the form I get these error messages:
6473
I have set the forgot password option
my controller function:
public function actionEmail_for_reset() {
if (isset($_POST['Members'])) {
$email = $_POST['Members']['email'];
$criteria = new CDbCriteria;
$criteria->condition = 'email=:email';
$criteria->params = array(':email' => $email);
$user = Members::model()->find($criteria);
if (!$user) {
$errormsg = Yii::t('passwordreset', 'Email ini tidak terdaftar. Silahkan coba lagi.');
Yii::app()->user->setFlash('error', $errormsg);
$this->refresh();
}
$key = md5(mt_rand() . mt_rand() . mt_rand());
$user->confirmation_code = $key;
$reset_url = $this->createAbsoluteUrl('site/password_reset', array('key' => $key, 'email' => $email));
$user->save();
if (XHtml::sendHtmlEmail(
$user->email, Yii::app()->name . ' Administrator', null, Yii::t('reset', 'Password reset.'), array('username' => $user->username, 'reset_url' => $reset_url), 'pwd_reset', 'main'
)
) {
$infomsg = Yii::t('passwordreset', 'We have sent you a reset link,please check your email inbox.');
Yii::app()->user->setFlash('info', $infomsg);
$this->refresh();
} else {
$errormsg = Yii::t('passwordreset', 'We could not email you the password reset link');
Yii::app()->user->setFlash('info', $errormsg);
$this->refresh();
}
}
$model = new Members;
$this->render('email_for_reset', array('model' => $model));
}
the form code
<div class="register-block black-text-color login-form">
<div class="register-block-header text-center">
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'EmailForm',
'type' => 'horizontal',
'enableAjaxValidation' => false,
'htmlOptions' => array('class' => 'form')
));
?>
<?php $this->widget('bootstrap.widgets.TbAlert'); ?>
<h3>Lupa Password</h3>
<!--<span class="label important">Fields with <span class="important">*</span> are required.</span>-->
</div>
<span class="line margin-20"></span>
<?php echo $form->errorSummary($model); ?>
<p>Kami akan mengirimkan password ke Email Anda</p>
<div class="form">
<div class="input-group margin-bottom-20">
<?php echo $form->textField($model, 'email', array('class' => 'form-control', 'placeholder' => "Enter your Email address", 'maxlength' => 256, 'style' => 'width:200px; height:30px; border-radius:5px; padding-left:10px;')); ?>
</div>
<?php // echo $form->error($model,'username'); ?>
<br>
<p>
<?php
$this->widget('bootstrap.widgets.TbButton', array(
'buttonType' => 'submit',
//'type' => 'primary',
'label' => $model->isNewRecord ? 'SEND PASSWORD' : 'Save',
'htmlOptions' => array('class' => 'btn-fp')
));
?>
</p>
</div>
</div>
<?php $this->endWidget(); ?>
</div>
my WebApplication.php file code is
class WebApplication extends CWebApplication {
/**
* This function is here because we aren't creating a locale file for every client.
* Thus we provide a fallback to "en".
*/
public function getLocale($localeID = null) {
try {
return parent::getLocale($localeID);
} catch (Exception $e) {
return CLocale::getInstance('en');
}
}
/**
* We were getting tons of errors in the logs from OPTIONS requests for the URI "*"
* As it turns out, the requests were from localhost (::1) and are apparently a way
* that Apache polls its processes to see if they're alive. This function causes
* Yii to respond without logging errors.
*/
public function runController($route) {
try {
parent::runController($route);
} catch (CHttpException $e) {
if (@$_SERVER['REQUEST_METHOD'] == 'OPTIONS' && @$_SERVER['REQUEST_URI'] == '*') {
Yii::app()->end('Hello, friend!');
} else
throw $e;
}
}
}
I am using this helper class
If anyone knows the solution then kindly share with me.