title: Controller function runs every time when page is refreshed using codeigniter
body: <p>I have a single button. When I clicked on the button then it's called the function demo inside my testcontroller.I have to call the view page called as <code>createsection</code> also I have to call the model(For sending an email which is working).</p>
  
  <p>After clicking on the button now I am on <code>createsection</code> page but when I fresh the page It's again calling demo function in the controller.</p>
  
  <p>I just need on a single click to call view and also call the model in the background. User will get the view page and model can send the email.</p>
  
  <p><strong>welcome.php</strong></p>
  
  <pre><code>&lt;?php echo form_open('testcontroller/demo'); ?&gt;
  &lt;button name="clicked"&gt;click me&lt;/button&gt;
  &lt;?php echo form_close(); ?&gt;
  </code></pre>
  
  <p><strong>testcontroller/demo</strong></p>
  
  <pre><code>class testcontroller extends CI_Controller {    
  public function demo(){
      $email=$this-&gt;session-&gt;userdata('email');
  
      $this-&gt;load-&gt;view('createsection');
  
      $this-&gt;load-&gt;model('user_model');
      $id=$this-&gt;user_model-&gt;new_user($email);//passing email id in model to send the email
  
      //more code here..............
  }
  }
  </code></pre>
  
  <p><strong>createsection (view page)</strong></p>
  
  <p>The user will get this page after clicking on the button.</p>
  
  <pre><code>   &lt;?php echo form_open('testcontroller/confirm'); ?&gt;
      &lt;input type="text" name="code"&gt;
      &lt;input type="submit" name="submit"&gt;
      &lt;?php echo form_close(); ?&gt;
  </code></pre>