Hi Experts,
I’m trying to reset password. when user clicks the link in his mail. he’ll be redirected to my controller as below…its checking and performing a check but I need to send user to resetpassword page and I need to capture new password so that i can save in my model according to that particular id.
I’m able to send user to resetpassword page but unable to get the resetpassword value and unable to find the record in my table.
Controller:
public function actionResetPassword(){
if(isset($_GET['verificationcode'])){
$verificationcode = $_GET['verificationcode'];
$record = User::model()->findByAttributes(array('reset_password' => $verificationcode));
if ($record === null){
throw new CHttpException('Invalid credentials.');}
else{
User::model()->updateByPk(
$record->id,
array('password'=>$verificationcode));
echo "your password checked you can use this password or you can reset new password";
$model=User::model()->findByPk($record->id);
//show the view with the password field
$this->render('resetpassword',array(
'model'=>$model,
));
//$this->render('setnewpassword'); //show the view with the setnewpassword field
}
}
elseif(isset($_POST['resetpassword']))
{
echo "yes";die;
$password = $_POST['resetpassword'];
$record = User::model()->findByAttributes(array('reset_password' => $verificationcode));
echo $password;die;
User::model()->updateByPk(
$record->id,
array('password'=>$password));
// $this->render('index');
// echo "done";
}
resetpassword view:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'password-form',
'enableClientValidation'=>true,
));
//echo CHtml::label('Enter your new password');
echo CHtml::textField('resetpassword');
//echo CHtml::submitButton('Reset My Password');
echo CHtml::submitButton($model->isNewRecord ? 'resetpassword' : 'Reset My Password');
$this->endWidget();
any help pls
Many Thanks,