小编crg*_*821的帖子

Codeigniter - 忘记密码

您好:我需要在登录页面上实现忘记密码.在这里,我解释了到目前为止我所拥有的

  1. 恢复视图提示收到电子邮件输入
  2. 功能email_exists()将验证电子邮件.如果是这样,send_email()使用$temp_pass密钥和链接.数据库将存储$ temp_pass以进行进一步的操作和验证.
  3. 用户点击之前发送的链接,传递$temp_pass给函数reset_password.
  4. 模型控制器将验证$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)

passwords codeigniter

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

codeigniter ×1

passwords ×1