In Codeigniter and other PHP applications, what’s generally considered the more efficient practice:
1.) Submitting a form to the same function using a hidden ‘submitted’ input:
public function standard_form()
{
if($this->input->post('submitted'))
{
// Process data
}
else
{
// Render form view
}
}
2.) Submitting a form to a different function as follows:
public function standard_form()
{
// Render form view
}
public function standard_form_process()
{
// Process data
}
I know some people will frown upon the ‘subjective’ nature of this question, but I want to know any strategic (i.e. relatively objective) benefits of using one instead of the other.
You use the same one so if it fails validation, and you reload the page, it’s the same URL, same bookmark, etc.