title: A PHP Error was encountered Severity: Notice Message: Undefined property: Site::$site_model
body: <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Undefined property: Site::$site_model</p>
    
    <p>Filename: controllers/site.php</p>
    
    <p>Line Number: 13 </p>
    
    <p>Site Controller site.php
    Fatal error: Call to a member function delete_row() on a non-object in
    C:\xampp\htdocs\login\application\controllers\site.php on line 13</p>
  </blockquote>
  
  <p>My <strong>controller</strong>->Site.php</p>
  
  <pre><code>&lt;?php 
  class Site extends CI_Controller{
      function __construct(){
        parent::__construct();
        $this-&gt;is_logged_in();
  
      }
      function delete(){
        $this-&gt;site_model-&gt;delete_row();
        $this-&gt;index();
      }
      function members_area(){
        $this-&gt;load-&gt;model('patient_model');
        $data['records'] = $this-&gt;patient_model-&gt;getAll();
        $this-&gt;load-&gt;view('members_area', $data);
      }
      function add(){
         $data['main_content'] = 'patient_form';
         $this-&gt;load-&gt;view('includes/template',$data);
      }
      function is_logged_in(){
         $is_logged_in = $this-&gt;session-&gt;userdata('is_logged_in');
          if(!isset($is_logged_in) || $is_logged_in != true){
            echo 'Your don\'t have permission to access this page. &lt;a href="../login"&gt;Login&lt;/a&gt;';
            die();
          }
      }
  } 
  </code></pre>
  
  <hr>
  
  <p>My <strong>model</strong> -> site_model.php</p>
  
  <pre><code>class Site_model extends CI_Model{
      function get_records(){
            $query = $this-&gt;db-&gt;get('patient');
             return $query-&gt;result();
      }
      function delete_row(){
            $this-&gt;db-&gt;where('id', $this-&gt;uri-&gt;segment(3));
            $this-&gt;db-&gt;delete('patient');
      }
      function create_member(){
            $new_member_insert_data = array(
            'fname' =&gt; $this-&gt;input-&gt;post('fname'),
            'lname' =&gt; $this-&gt;input-&gt;post('lname'),
            'email' =&gt; $this-&gt;input-&gt;post('email'),
            'address' =&gt; $this-&gt;input-&gt;post('address'),
            'contact' =&gt; $this-&gt;input-&gt;post('contact'),
            'remarks' =&gt; $this-&gt;input-&gt;post('remarks')
      );
      $insert = $this-&gt;db-&gt;insert('patient', $new_member_insert_data);
      return $insert;
      }
  }
  </code></pre>
  
  <hr>
  
  <p>My <strong>view</strong>-> members_area.php</p>
  
  <pre><code>&lt;?php $this-&gt;load-&gt;view('includes/header');?&gt;
  
  &lt;div id="main"&gt;
  Welcome Back, &lt;u&gt;&lt;?php echo $this-&gt;session-&gt;userdata('username'); ?&gt;!&lt;/u&gt;
  &lt;h3&gt;Vision Eye Medical Center Patient Information&lt;/h3&gt;
  
  &lt;div id="overflow"&gt;
    &lt;table class="features-table"&gt;
  
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;td&gt;Patient Name&lt;/td&gt;
              &lt;td&gt;Email&lt;/td&gt;
              &lt;td&gt;Address&lt;/td&gt;
              &lt;td&gt;Contact&lt;/td&gt;
              &lt;td&gt;Remarks&lt;/td&gt;
              &lt;td&gt;Action&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
  
          &lt;tfoot&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;-&lt;/td&gt;
              &lt;td&gt;-&lt;/td&gt;
              &lt;td&gt;-&lt;/td&gt;
              &lt;td&gt;-&lt;/td&gt;
              &lt;td&gt;-&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tfoot&gt;          
          &lt;tbody&gt;
          &lt;?php foreach($records as $row): ?&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;fname;?&gt;
                &lt;?php echo $row-&gt;lname;?&gt;
              &lt;/td&gt;
  
              &lt;td&gt;&lt;?php echo $row-&gt;email;?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;address;?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;contact;?&gt;&lt;/td&gt;      
              &lt;td&gt;&lt;?php echo $row-&gt;remarks;?&gt;&lt;/td&gt;      
              &lt;td&gt;View|&lt;?php echo anchor("site/delete/$row-&gt;id",'delete');?&gt;&lt;/td&gt;     
            &lt;/tr&gt;
  
            &lt;?php endforeach; ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
   &lt;/div&gt;   
    &lt;?php echo form_open();?&gt;
       &lt;?php echo anchor('patient/add', 'Add new Data'); ?&gt;&lt;?php echo anchor('login/logout', 'Logout'); ?&gt;&lt;br&gt;
      &lt;?php echo form_close();?&gt;
  
  &lt;/div&gt;
  &lt;?php $this-&gt;load-&gt;view('includes/footer');?&gt;
  </code></pre>