Welcome Guest, Not a member yet? Register   Sign In
Need Help User Edit Not Updating Username
#1

[eluser]razerone[/eluser]
Hi I am trying to get it so can update my username setting user_id not working Every thing else is ok just in this section some where

Code:
public function user_edit() {<-- Here and

if ($this->input->post('btn-save')) {
$this->admin_model->user_edit();
if ($this->admin_model->error_count != 0) {
$this->data['error']    = $this->admin_model->error;
} else {
$this->session->set_userdata('tmp_success', 1);
redirect('admin/user_view');
}
}
        
$this->db->order_by('role', 'ASC');
$this->data['roles']   = $this->db->get('cws_roles')->result();
$this->data['users']    = $this->db->get_where('cws_users', $user_id)->row();<-- Here error
$this->data['title']   = 'Admin Users';
$this->load->view('header', $this->data);
$this->load->view('admin/user_edit');
$this->load->view('footer');
}
#2

[eluser]CroNiX[/eluser]
You pass $user_id here, but where is it defined?
Code:
$this->data['users']    = $this->db->get_where('cws_users', $user_id)->row();<-- Here error
#3

[eluser]razerone[/eluser]
[quote author="CroNiX" date="1387922418"]You pass $user_id here, but where is it defined?
Code:
$this->data['users']    = $this->db->get_where('cws_users', $user_id)->row();<-- Here error
[/quote]

I have it in my admin controller and admin model I am making a forum site
#4

[eluser]razerone[/eluser]
[quote author="CroNiX" date="1387922418"]You pass $user_id here, but where is it defined?
Code:
$this->data['users']    = $this->db->get_where('cws_users', $user_id)->row();<-- Here error
[/quote]


Admin Model

Code:
public function user_edit()
    {
        $row = $this->input->post('row');

        if ($row['password'] != "" || $row['password2'] != "") {

            if ($row['password'] != $row['password2']) {

                $this->error['password'] = 'Password not match';

            } else if (strlen($row['password']) < 5) {

                $this->error['password'] = 'Password minimum 5 character';

            }
        }      
        
        if (count($this->error) == 0) {
            
            if ($row['password'] != "" && $row['password2'] != "") {

                $key = $this->config->item('encryption_key');

                $row['password'] = $this->encrypt->encode($row['password'], $key);

            } else {

                unset($row['password']);
            }
            
            unset($row['password2']);
            
            $this->db->where('id', $row['id']);

            $this->db->update('cws_users', $row);
            
        } else {
            $this->error_count = count($this->error);
        }
    }


Admin Controller


Code:
public function user_edit($user_id) {

        if ($this->input->post('btn-save')) {

            $this->admin_model->user_edit();

            if ($this->admin_model->error_count != 0) {

                $this->data['error']    = $this->admin_model->error;

            } else {

                $this->session->set_userdata('tmp_success', 1);
                
                redirect('admin/user_view');

            }
        }
        
        $this->db->order_by('role', 'ASC');
        $this->data['roles']   = $this->db->get('cws_roles')->result();
        $this->data['users']    = $this->db->get_where('cws_users', array('id' => $user_id))->row();
        $this->data['title']   = 'Admin Users';
        $this->load->view('header', $this->data);
        $this->load->view('admin/user_edit');
        $this->load->view('footer');
    }




Theme © iAndrew 2016 - Forum software by © MyBB