php - Saving user ID to database using CodeIgniter -


i trying create application users can enrol on course. enrol user has approved admin. user select course clicking on course,then course id , user id should saved in database. can't user id save in database. have added user id part of session. how can save user id in session?

here model:

         public function select_course() {  $data['users_id']=$this->input->post($this->session->userdata('users_id'));      $query =$this->db->insert('gp_approval_course',$data);      if ($query)     {         return true;     }     else     {         return false;     }     } 

here controller:

 public function add_course()  {          $this->load->model('model_users');           if ($this->model_users->select_course())         {         echo "you have selected course enroll on to!";         echo ($this->session->userdata('users_id'));         return true;         }         else          {          echo "database problem";          return false;         }    } 

change

$data['users_id']=$this->input->post($this->session->userdata('users_id')); 

to

$data['users_id']=$this->session->userdata('users_id'); $data['course_id'] = $this->input->post('your_course_id_var'); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -