dongtuo8170 2014-10-20 09:43
浏览 47
已采纳

如何在codeigniter中创建重置密码功能?

Whenever i run this code, i recieve a blank screen on submission. The code does not seem to work and i'm unsure why. Can anyone see an issue? I've checked it for syntax already mutliple times.

Controller:

public function changepwd(){
    $this->form_validation->set_rules('oldpassword','Old Password','required|trim|xss_clean|callback_change');
    $this->form_validation->set_rules('password1','New Password','required|trim');
    $this->form_validation->set_rules('password2','Confirm Password','required|trim|matches[password1]');

if($this->form_validation->run()= true){
    redirect('admin');
   }else{
$this->form_validation->set_message('change','info is wrong');
redirect('admin');  
}
}

public function change(){
$this->load->view('error_display');
$oldpass = $this->input->post('oldpassword');
if(isset($oldpass)){
    if($this->input->post('password1') == $this->input->post('password2')){

        $session=$this->session->userdata("logged_in");
        $username= $session['username'];

            $query = "SELECT * FROM database where username='$username'";
            $result = $this->db->query($query);
            $row=$result->row();
            $pass = $row->password;
            $s= $row->salt;
            $user_old_pass = sha1($s.$oldpass);

            if($pass == $user_old_pass){
                $new = substr(uniqid(rand(), true), 0, 20);
                $users_password = $this->input->post('pass1');
                $new_password = sha1($new.$user_password);
                $data = array($new,$new_password);  
                $this->update_model->insert_model($data);
                $this->form_validation->set_message('change','saved');
                $this->load->view('admin');

            }else{
                $this->form_validation->set_message('change','<p class="error">Incorrect Password</p>');
                return false;
                redirect('admin');  
            }
    }else{
        $this->form_validation->set_message('change','passwords dont match');
        return false;   
        redirect('admin');
    };

}else{
    $this->form_validation->set_message('change','old password is not entered');
    return false;
    redirect('admin');
}

model:

 function login($data)
    {
    $this->db->update('database', $data);
       }
  • 写回答

1条回答 默认 最新

  • dpsr1670 2014-10-20 09:46
    关注

    your

    if($this->form_validation->run()= true){
    

    should be

       if($this->form_validation->run() == FALSE) {
    

    because you are redirecting every time to 'admin'

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作