Welcome Guest, Not a member yet? Register   Sign In
Codeigniter sessions, and putting information into my database?
#1

[eluser]scm22ri[/eluser]
Hi Everyone,

I'm having an issue with Codeigniter sessions and inserting data into a database. My goal is to not pass the user_id in a form but when they insert their data I want my database to accept the submitted information along with the user_id. (Their user_id is a number).

In my view I have this syntax. I'm storing my user ID in a session.
Code:
$userid = $this->session->userdata('id');
$this->session->set_userdata('user_id', $userid);

In my model I've made two functions. They are below.
Code:
function submit_info(){
     $now = date("Y-m-d H:i:s");
  $data['time'] = $now;
  $data['car_id'] = $this->input->post('car_id',TRUE);
  $data['claim_statement'] = $this->input->post('claim_statement',TRUE);
  return $data;
   }

Code:
function submit_claim(){
    $data = $this->submit_claim_info();
    $this->db->insert('claim', $data);
  }

Code:
Database configuration
id
car_id
user_id
claim_statement
time

The above syntax accepts everything but the user_id which is the most important part of the equation. What am I doing wrong? How would I get my database to accept the user_id?

Thanks everyone




Theme © iAndrew 2016 - Forum software by © MyBB