how would i allow a user to edit their own account details. When they login, a session is created with their username. How do i query the database where i match the session to a user in the database? Im confused as to where to do it, controller, or model? Here is my code. Its not much because i really don't know where to start with this:
Controller:
public function myaccount()
{
if($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$data['id'] = $session_data['id'];
$this->myaccount_model->get_details($data);
$this->load->model('myaccount_model');
$this->load->view('head');
$this->load->view('myaccount', $data);
$this->load->view('footer');
}
else
{
redirect('login', 'refresh');
}
}
Model:
<?php
class Myaccount_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
public function get_details()
{
$query = $this->db->get_where('users', array('id' => $id));
return $query->row_array();
}
}
I am getting the error message :Undefined property: Navigate::$myaccount_model.
I know its something to do with how I'm passing the users id from the controller to the model?