Forgot Password Functionality

I want to perform forgot password functionality in my existing website. could please guys guide me how will I perform it.As I am new in YII.

THanks,

Have you save email address or mobile no of user?

Than,user will enter his login account,you have to fetch mobile no/email of it.

Just make a random number string,reset his password with that number,send message on mobile through curl,or send it by mail.

Thanks for you replay.

yes I have stored emailID in database.Please attach here all the script including model,view & controller.with validation and all thing.

Please try to do yourself.If any error occure , share here,will help you.

Hi Nitin try this way may be this will help to you




public function actionForgotPassword() {

    	$model = new User('passwordReset');

    	$model->setScenario('forgotPassword');

    	$hash = '';

    	if (isset($_POST['User'])) {

        	$model->attributes = $_POST['User'];

        	if ($model->validate()) {

            	$model = User::model()->findByEmail($_POST['User']['email']);

            	$timestamp = time();

            	$hash = crypt($model->email . $model->password . $timestamp);

            	Shared::debug($hash);

            	$model->password_reset = $timestamp;

            	// save the timestamp (password reset is good for 24 hours only)

            	$model->save();


            	$mail = new Mailer('forgotPass', array('hash' => $hash));

            	/**

             	* Be sure to configure properly! Check https://github.com/Synchro/PHPMailer for documentation.

             	*/

            	$mail->render();

            	$mail->From = app()->params['adminEmail'];

            	$mail->FromName = app()->params['adminEmailName'];

            	$mail->Subject = app()->name . ' Password Reset';

            	$mail->AddAddress($model->email);

            	if ($mail->Send()) {

                	$mail->ClearAddresses();

                	app()->user->setFlash('success', 'Please check your email for further instructions.');

                	$this->redirect(array('/site/index'));

            	} else {

                	app()->user->setFlash('error', 'Error while sending email: ' . $mail->ErrorInfo);

            	}

        	}

    	}

    	$this->render('forgot_password', array('model' => $model));

	}



All the best…

I was done with all the forgot password functionality.

Thanks for your support here.