2017-10-17 1 views
0
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); 
    } 
+0

de votre code, si votre nouveau mot de passe est le même que n'importe quel mot de passe dans la base de données, il affichera une erreur. – geeth

Répondre

0

Cette ligne mispelled « repass » il devrait être « de retype_password »

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

maintenant il ne montre pas l'erreur bt mot de passe ne change pas .. –