您好:我需要在登录页面上实现忘记密码.在这里,我解释了到目前为止我所拥有的
email_exists()将验证电子邮件.如果是这样,send_email()使用$temp_pass密钥和链接.数据库将存储$ temp_pass以进行进一步的操作和验证.$temp_pass给函数reset_password.$temp_pass数据库.如果是这样,加载视图以输入新密码 - 这就是我被卡住的地方,因为表单指向一个无法识别的控制器$temp_pass因此无法重置密码.如何检索与正确用户关联的新密码并重置密码?
代码如下:
public function recover(){
//Loads the view for the recover password process.
$this->load->view('recover');
}
public function recover_password(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|callback_validate_credentials');
//check if email is in the database
$this->load->model('model_users');
if($this->model_users->email_exists()){
//$them_pass is the varible to be sent to the user's email
$temp_pass = md5(uniqid());
//send email with #temp_pass as a link
$this->load->library('email', array('mailtype'=>'html'));
$this->email->from('user@yahoo.com', "Site");
$this->email->to($this->input->post('email'));
$this->email->subject("Reset your …Run Code Online (Sandbox Code Playgroud)