CodeIgniter Forums
why does form on validation error redirect back to last function... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: why does form on validation error redirect back to last function... (/showthread.php?tid=51675)



why does form on validation error redirect back to last function... - El Forum - 05-13-2012

[eluser]Unknown[/eluser]
Hi all,
running into an issue where my form is on say /member/register/ ->
then the user submits, but there is validation errors ->
so i reload the index of that function 'Register' ... but (the URL shows and) it brings me to the last function i was in /member/register/submit/ something like that - what am i missing?
how do i get it to reload /member/register/ instead of /member/register/submit?!?
*shortened the code below but you should get the idea...

Thanks in advance

Code:
class Register extends CI_Controller
{
function index()
{
  $data['main_content'] = 'reg_signup_view';
  $this->load->view('includes/template', $data);
}

function submit()
{
  $this->load->library('form_validation');

  // field name, error message, validation rules
  $this->form_validation->set_rules('fname', 'First Name', 'trim|required');

  if($this->form_validation->run()== FALSE)
  {
     //both of these ways have the same outcome
     //$this->load->view('reg_signup_view');
   //$this->index();
    $data['main_content'] = 'reg_signup_view';
   $this->load->view('includes/template', $data);
  }
  else
  {

     $data['main_content'] = 'signup_successfull';
    $this->load->view('includes/template', $data);

  }
}
}