2014-10-20 150 views
0

每当我运行这段代码时,我都会在提交时收到一个空白屏幕。代码似乎不起作用,我不确定为什么。任何人都可以看到问题吗?我已经检查过它的语法已经多次。如何在codeigniter中设置重置密码功能?

控制器:

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'); 
} 

型号:

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

回答

0

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

应该

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

,因为你每次重定向到'admin'

+0

啊,没有更多的空白页面,只是我需要修复的错误。谢谢!你能看到任何可能与代码有关的错误吗? – Bakitai 2014-10-20 09:49:36

+0

您可以在页面中看到哪些错误? – 2014-10-20 09:50:11

+0

这是当前“调用成员函数insert_model()在非对象” – Bakitai 2014-10-20 09:50:46