![]() |
how to redirect to welcome controller without removing validation_errors (); - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: how to redirect to welcome controller without removing validation_errors (); (/showthread.php?tid=31247) |
how to redirect to welcome controller without removing validation_errors (); - El Forum - 06-11-2010 [eluser]my9006ci[/eluser] i have welcome controller Code: <?php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Code: <?php Code: $this->load->view('myform'); Code: $this->load->view('formsuccess'); how to redirect to welcome controller without removing validation_errors (); - El Forum - 06-11-2010 [eluser]daelsepara[/eluser] you can use session flashdata: Code: $this->session->set_flashdata('validation_errors', 'put the error message here'); in your welcome controller: Code: if ($this->session->flashdata('validation_errors')) $data['validation_errors'] = $this->session->flashdata('validation_errors'); in your welcome views: Code: <?php if (!empty($validation_errors)) print "<div class = \"error\">$validation_errors</div>\n"; ?> how to redirect to welcome controller without removing validation_errors (); - El Forum - 06-11-2010 [eluser]mddd[/eluser] I think part of the problem is in the fact that your form's target is a different page then where the form is on. Now you have a page with a login form, and a page that shows 'your are logged in', but also has to show the form again in case of errors! So, there are two places that have to handle the form. I think it's a better solution to post the form to its own url. If there are problems, you can show them there. In the same form you are using already. In the login library, you check if everything is okay, and if it is, you redirect the user to the "you are logged in" page. how to redirect to welcome controller without removing validation_errors (); - El Forum - 06-11-2010 [eluser]my9006ci[/eluser] [quote author="daelsepara" date="1276267798"]you can use session flashdata: Code: $this->session->set_flashdata('validation_errors', 'put the error message here'); in your welcome controller: Code: if ($this->session->flashdata('validation_errors')) $data['validation_errors'] = $this->session->flashdata('validation_errors'); in your welcome views: Code: <?php if (!empty($validation_errors)) print "<div class = \"error\">$validation_errors</div>\n"; ?> good idea @daelsepara thanks |