在yii中,我正在创建忘记密码功能。 单击忘记密码按钮后,服务器将提供一个带有空白文本字段的PHP PAGA,用于输入主要电子邮件ID。现在如何在控制器的方法中检索此电子邮件ID,以及如何检查此电子邮件ID是否存在于databse中。请帮帮我...
这将帮助您入门,您将在控制器中放置一个与此类似的方法,并创建一个带有密码字段的视图。
public function actionForgotPassword(){
if(isset($_POST['email']{
$record=User::model()->find(array(
'select'=>'email',
'condition'=>'email=:email',
'params'=>array(':email'=>$_POST['email']))
);
if($record===null) {
$error = 'Email invalid';
} else {
$newpassword = 'newrandomgeneratedpassword';
$record->password = md5($newpassword );
$record->save(); //you might have some issues with the user model when the password is protected for security
//Email new password to user
}
}else{
$this->render('forgetPassword'); //show the view with the password field
}
}