php - Error while submitting password-reset form -
i have password-reset form within yii-framework site. when user submits form these error messages:
i have set 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 reset link,please check email inbox.'); yii::app()->user->setflash('info', $infomsg); $this->refresh(); } else { $errormsg = yii::t('passwordreset', 'we not email password reset link'); yii::app()->user->setflash('info', $errormsg); $this->refresh(); } } $model = new members; $this->render('email_for_reset', array('model' => $model)); }
form:
<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 <span class="important">*</span> 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 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
class webapplication extends cwebapplication { /** * function here because aren't creating locale file every client. * provide fallback "en". */ public function getlocale($localeid = null) { try { return parent::getlocale($localeid); } catch (exception $e) { return clocale::getinstance('en'); } } /** * getting tons of errors in logs options requests uri "*" * turns out, requests localhost (::1) , apparently way * apache polls processes see if they're alive. function causes * yii 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 using this helper class
i have solved issue describing 'mailer' component in config/main.php file.
'mailer' => array( 'class' => 'common.extensions.mailer.emailer', ),
Comments
Post a Comment