Im trying to allow a user to edit their own details. Here is my code: Controller:

public function myaccount() {
    if($this->session->userdata('logged_in')) {
        $session_data = $this->session->userdata('logged_in');
        $data['id'] = $session_data['id'];
        $this->load->view('myaccount', $data);
    } else {
        redirect('login', 'refresh');


class Myaccount_model extends CI_Model {

    public function __construct() {

    public function get_details($data) {
        $query = $this->db->get_where('users', array('id' => $id));
        return $query->row_array();

It comes up with the error :Undefined variable $id on my account_model. The session is created at the controller as:

$data['id'] = $session_data['id'];

So how do i pass the data from the controller, to the model so i can query the database and select the user that matches the session id? Thanks

Related posts

Recent Viewed