title: Codeigniter: passing a post variable from one function to another in a controller
body: <p>Am getting a variable called $msisdn from a view using post in one function (search_results). After doing the processing, I would like to use the same variable in another function(assign_role) currently,I am unable to do that since am getting this error </p>
  
  <blockquote>
    <p>Severity: Notice Message: Undefined variable: msisdn</p>
  </blockquote>
  
  <p>. Below is my search_result function where am getting the post data:</p>
  
  <pre><code>public function search_results(){
  
      $msisdn =  $this-&gt;input-&gt;post('search_data');//getting data from the view
  
  
      if ($msisdn == false){
  
          $this-&gt;load-&gt;view('add_publisher');
  
      } else{
          $this-&gt;assign_role($msisdn); //passing the variable to another function
  
          $this-&gt;load-&gt;model('search_model');
  
  
          $data['result'] = $this-&gt;search_model-&gt;search_user($msisdn);
          $data1['box'] = $this-&gt;search_model-&gt;search_select($msisdn);
  
          $result = array_merge($data, $data1);  
  
          $this-&gt;load-&gt;view('add_publisher',$result);
  
          echo json_encode($result);
      }
  
  } 
  </code></pre>
  
  <p>I want to use $msisdn from above function in this function below:</p>
  
  <pre><code>public function assign_role($msisdn){
  
      //echo $msisdn['numm'];
  
      $publisher = $this-&gt;input-&gt;post('select');
  
      if ($publisher == false) {
  
          $this-&gt;load-&gt;view('add_publisher');
  
      } else {
  
          $data = array(
             'publisher' =&gt; true,
          );
  
          $this-&gt;load-&gt;model('insert_model');
  
          $data1 = $this-&gt;insert_model-&gt;search_group($msisdn, $data);             
  
              if ($data1 == true) {
  
                  echo "Recorded updated succesfully";
                  $this-&gt;load-&gt;view('add_publisher');
  
              } else {
  
                  echo "Recorded not updated";
                  $this-&gt;load-&gt;view('add_publisher');
  
              }
  
      }
  
  }
  </code></pre>
  
  <p>Please help me to achieve this.</p>