title: Codeigniter URL problem! Hitting refresh causes functions to be executed!
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6885287/how-to-access-a-variable-in-a-php-class-that-is-set-by-another-function-codeigni">How to access a variable in a PHP class that is set by another function? Codeigniter</a>  </p>
  </blockquote>
  
  
  
  <p>I have a controller called submit:</p>
  
  <p>Basically it does two things of concern:</p>
  
  <ol>
  <li><strong>validate_form()</strong> - It validates a form -> then submits to
  database.</li>
  <li><strong>success()</strong> - It loads a page giving feedback on whether the
  previous operation was successfull.</li>
  </ol>
  
  <p>My controller works fine however there is a slight problem in when it loads my success page.
  If you hit <strong>Refresh</strong> the "success" page it would for some reason cause my validate_form() function to run again causing the same data to be duplicated in the database.</p>
  
  <p><strong>What I want is that when the user goes to success page they can hit refresh as many times they like and it wont call any functions etc.</strong></p>
  
  <p>My url on the success view is </p>
  
  <blockquote>
    <p><a href="http://localhost/site/validate_form" rel="nofollow noreferrer">http://localhost/site/validate_form</a></p>
  </blockquote>
  
  <p>I am guessing this is the problem because it is still in the validate_form() function.</p>
  
  <p>My validate form function loads the success view by calling another function within it?
  Here is my code:</p>
  
  <pre><code>//Record ID = returned value
                          $record_id = $this-&gt;submit_model-&gt;create_record($completedstaffrows, $completedeventrows);
  
                          //if no value returned call failed function
  
                          if ($record_id == FALSE)
                          {
                              $this-&gt;failed();
                          }
  
                          //Submittal to database was successful
                          //Now call function to load success view
                          else
                          {
  
                              $this-&gt;success();
                          }
  </code></pre>
  
  <p>My function for loading success view:</p>
  
  <pre><code>    public function success()
          {
              $page['page'] = 'success';
  
              $this-&gt;load-&gt;view('template', $page );
  
          }
  </code></pre>