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