A small tip for codeigniter programmers.

code-igniter-logo

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
<br></br>
if (count($_POST) > 0)

``

{

$this->session->setuserdata('postdata', $POST );
redirect('same
controller');

}

else

{

if($this->session->userdata('post_data'))
{

$POST = $this->session->userdata('postdata');

$this->session->unsetuserdata('postdata');
}

}

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)