Codeigniter – Post resubmit problem on refresh
A small tip for codeigniter programmers.

If you use same controller for display view page and take action on POST, there is a problem may happen when you try to refresh the page after submit, the whole data get re-submit and creates problem.
It can be solved using session. If there is any POST form submit,
ie
if (count($_POST) > 0)
{
$this->session->set_userdata('post_data', $_POST );
redirect('same_controller');
}
else
{
if($this->session->userdata('post_data'))
{
$_POST = $this->session->userdata('post_data');
$this->session->unset_userdata('post_data');
}
}
This will solve the problem of resubmit !!!
Or simply you can use another controller for POST method and separate the form display using another controller (Normal way)

No need to use another controller for POST method.
USE same controller with some method like..
———–your_controller———–
index(){
//YOUR controller DATA
}
save(){
//GET YOUR POST DATA HERE
//SAVE YOUR POST DATA
redirect(‘your_controller’);
}
Thank you! I struggled with what to do about this for well over an hour.
Thank you. You save of my life