how to redirect to welcome controller without removing validation_errors (); |
[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');
[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"; ?>
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |