title: How to setup this data to work with a view and a model
body: <p>I am having issues not sure how I would set this up with model, view and controller. I am new to codigniter and a bit lost still learning. I set everything up in the controller which I know now it is wrong the page comes up with page cannot display when I insert a record after I hit submit. when it should just redirect me back to were I inserted the record. </p>
  
  <p>employee controller</p>
  
  <pre><code> &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
      class Employee extends CI_Controller {
      function __construct()
  {
      parent::__construct();
      $this-&gt;load-&gt;model('employee_model');
  
      }   
  
      //Insert the employee 
          public function  insert_employee()
          { 
  
  
              $data=array('name'=&gt;$this-&gt;input-&gt;post('name'),
                  'LanId'=&gt;$this-&gt;input-&gt;post('LanId'),
                  'reason'=&gt;$this-&gt;input-&gt;post('reason'),
                  'PepNumber'=&gt;$this-&gt;input-&gt;post('PepNumber'),
                  'Employee_Number'=&gt;$this-&gt;input-&gt;post('Employee_Number'),
                  'department'=&gt;$this-&gt;input-&gt;post('department'),
  
                  'status'=&gt;1);
              //print_r($data);
  
              $result=$this-&gt;employee_model-&gt;insert_employee($data);
              if($result==true)
              {
                  $this-&gt;session-&gt;set_flashdata('msg',"Employee Records Added Successfully");
                  redirect('employee/index');
  
              }
              else
              {
  
                  $this-&gt;session-&gt;set_flashdata('msg1',"Employee Records Added Failed");
                  redirect('employee/index');
  
  
              }
          }
  </code></pre>
  
  <p>employee model </p>
  
  <pre><code>&lt;?php
  
  class Employee_model extends CI_Model 
  {
  
      public function insert_employee($data)
      {
          $this-&gt;db-&gt;insert('employee_list',$data);
          return ($this-&gt;db-&gt;affected_rows() != 1 ) ? false:true;
      }
      public function get_employee()
      {
          $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('employee_list');
          $this-&gt;db-&gt;where('status',1);
  
          $query =$this-&gt;db-&gt;get();
          return $query-&gt;result();
      }
      public function delete_employee($id,$data)
      {
          $this-&gt;db-&gt;where('id',$id);
          $this-&gt;db-&gt;update('employee_list',$data);
          return ($this-&gt;db-&gt;affected_rows() != 1 ) ? false:true;
      }
      public function edit_employee($id)
      {
          $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('employee_list');
          $this-&gt;db-&gt;where('id',$id);
          $this-&gt;db-&gt;where('status',1);
          $query =$this-&gt;db-&gt;get();
          return $query-&gt;result();
  
      }
      public function update_employee($data,$id)
      {
          $this-&gt;db-&gt;where('id',$id);
          $this-&gt;db-&gt;update('employee_list',$data);
          return ($this-&gt;db-&gt;affected_rows() != 1 ) ? false:true;
      }
  }
  </code></pre>