当我更改密码“新密码字段与遣返字段不匹配”时,我收到错误mgs

时间:2017-10-17 06:46:54

标签: php codeigniter

public function change_password()
{
if($_POST)
{
   $this->load->library('form_validation');
   $this->form_validation->set_rules('old_password', 'Old Password', 'required');
    $this->form_validation->set_rules('new_password', 'New Password', 'required|matches[repass]');
    $this->form_validation->set_rules('retype_password', 'Repeat Password', 'required');
    if (!$this->ion_auth->logged_in())
    {
    redirect(base_url(), 'refresh');
    }
    $user = $this->ion_auth->user()->row();

    if ($this->form_validation->run() == TRUE)
    {
    $pass=$this->input->post('oldpass');
                   $npass=$this->input->post('new_password');
                   $rpass=$this->input->post('retype_password');

                  $change = $this->ion_auth->change_password($this->session->email, $pass, $npass);
                   if ($change)
    {
    //if the password was successfully changed
    $this->session->set_flashdata('message_success', $this->ion_auth->messages());
    $this->logout();
    }
    else
    {
    $this->session->set_flashdata('message_error', $this->ion_auth->errors());
    redirect('user/profile', 'refresh');
    }

    }
    else
    {
    echo validation_errors();exit;
    }
        }

       //$this->load->model('Profile_m');
    //$this->db->update('users',$data,array('id'=>$user_id));
    $this->data['subview']='Page/profile';
    $this->load->view('__layout_admin',$this->data);
    }

1 个答案:

答案 0 :(得分:0)

这条线错误地重复了#39;它应该是' retype_password'

$this->form_validation->set_rules('new_password', 'New Password', 'required|matches[retype_password]');