Possible Duplicate:
How to access a variable in a PHP class that is set by another function? Codeigniter
I have a controller called submit:
Basically it does two things of concern:
- validate_form() - It validates a form -> then submits to database.
- success() - It loads a page giving feedback on whether the previous operation was successfull.
My controller works fine however there is a slight problem in when it loads my success page. If you hit Refresh 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.
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.
My url on the success view is
I am guessing this is the problem because it is still in the validate_form() function.
My validate form function loads the success view by calling another function within it? Here is my code:
//Record ID = returned value
$record_id = $this->submit_model->create_record($completedstaffrows, $completedeventrows);
//if no value returned call failed function
if ($record_id == FALSE)
{
$this->failed();
}
//Submittal to database was successful
//Now call function to load success view
else
{
$this->success();
}
My function for loading success view:
public function success()
{
$page['page'] = 'success';
$this->load->view('template', $page );
}