How send user back to homepage after Form controller is complete? [SOLVED] |
[eluser]CoderReborn[/eluser]
On my homepage, I have a Form that calls a controller named "doing_form" when the user clicks the Submit button. In my controller code, after I've handled the form, I want to send the user back to the homepage (http://localhost) - preferably with a success message, too. How do I do this? Thanks!
[eluser]Simian Studios[/eluser]
Easiest way to do this would be to redirect() them back to the homepage, and then use flashdata to show the message - you would just have to output the flashdata in your template. First step is to auto-load the session library (if you aren't already), so do that in system/application/config/autoload.php So in your controller you would have something like the following: Code: $this->load->helper('url'); // if not already loaded And then drop the following line into your homepage template (or even better, the overall layout so you could show flashdata on any page): Code: <?php echo $this->session->flashdata('message'); ?> For more info on flashdata and how it works, check out the manual page on sessions.
[eluser]CoderReborn[/eluser]
Thanks! This was helpful. I had to pass in the name of my "home" controller into the redirect() helper. "/" did not work. |
Welcome Guest, Not a member yet? Register Sign In |