title: CodeIgniter - Refer Url - Saved In Database
body: <p>i need to save a refer url in database, for example user see an advertise on facebook and click on link when the user comes only database save the url in database for this i make a function but i didn't get exactly of function please suggest.</p>
  
  <blockquote>
    <p>welcome.php controller</p>
  </blockquote>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Welcome extends CI_Controller {
  public function index()
  {
      $this-&gt;load-&gt;library('user_agent');
      $this-&gt;load-&gt;helper('url');
      $refer_url =  $this-&gt;input-&gt;get("refer_url");
      $this-&gt;Users_model-&gt;refer_data($refer_url);
  
      if ($this-&gt;input-&gt;get("lang") =="en"){
          if ($this-&gt;agent-&gt;is_mobile()) {
              $this-&gt;load-&gt;view('m_english_signup');
          }
          else {
              $this-&gt;load-&gt;view('d_english_signup');
          }
      }
  
  elseif($this-&gt;agent-&gt;is_mobile())
       {
          $this-&gt;load-&gt;view('m_arabic_signup');
  }
  else {
      $this-&gt;load-&gt;view('d_arabic_signup');
  }
  }
  </code></pre>
  
  <blockquote>
    <p>user_model.php</p>
  </blockquote>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
      class Users_model extends CI_Model
      {
  
  
      function create_member()
      {
              $new_member_insert_data = array(
                  'email' =&gt; $this-&gt;input-&gt;post('email'),
                  'city' =&gt; $this-&gt;input-&gt;post('city'),                           
              );
              $insert = $this-&gt;db-&gt;insert('users', $new_member_insert_data);  
          return $insert;
  
  
      }   //create_member
  
      function refer_data($arg)
      {
          $refer_data = array(
                  'refer_url' =&gt; $arg,                
              );
              $insert = $this-&gt;db-&gt;insert('refer', $refer_data);  
          return $insert; 
  
      }   //refer_data
  
  }
  </code></pre>
  
  <p><strong>Errors</strong></p>
  
  <blockquote>
    <p>Fatal error: Call to a member function refer_data() on a non-object in
    /home/content/f/a/h/fahadghafoor/html/fahad/application/controllers/welcome.php
    on line 9</p>
  </blockquote>