Welcome Guest, Not a member yet? Register   Sign In
Change URL after form validation inside controller
#1

[eluser]Unknown[/eluser]
I have a basic page with a form and two input text fields.
Upon submition, i route to my controller with method do_something.

Code:
public function do_something() {
$this->form_validation->set_rules('field_one', 'Field Two', 'required');
$this->form_validation->set_rules('field_two', 'Field Two', 'required');

if ($this->form_validation->run() === FALSE) {
  $this->load->view('basic_page', $data);
} else {
  $this->load->view('success', $data);
}
}

If validation fails, i load the same page i was in the first place, so i can show the error messages (just like the Form Validation documentation).
The page is shown, and the errors are there, but the address now is http://localhost/do_something (do_something instead of basic_page).
Is there a way to keep the original URL when returning from validation === FALSE?

Thanks,

Jose




Theme © iAndrew 2016 - Forum software by © MyBB