Difference between Redirect en load-view - 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: Difference between Redirect en load-view (/showthread.php?tid=56831) |
Difference between Redirect en load-view - El Forum - 01-23-2013 [eluser]Unknown[/eluser] After a form submit, and the data is wrong.. what's the difference between using $this->load->view('bla') or redirect('blog/post') Here is my full code for now.. Code: function comment($id){ Thanks! Difference between Redirect en load-view - El Forum - 01-24-2013 [eluser]Harold Villacorte[/eluser] If you want to access Ci's form validation errors use load->view(). If you want flashdata use redirect(). Difference between Redirect en load-view - El Forum - 01-24-2013 [eluser]Aken[/eluser] Have you read the user guide descriptions of each item? redirect() sends a Location header and literally redirects the browser to a specific URL. $this->load->view() loads a view file and sends it to the output class to be displayed to the browser. Difference between Redirect en load-view - El Forum - 01-25-2013 [eluser]Unknown[/eluser] [quote author="Harold Vilacorte" date="1359088135"]If you want to access Ci's form validation errors use load->view(). If you want flashdata use redirect().[/quote] Well i want to load the view.. but it's a dynamic view.. it loads a current post -> blog/post/4 so how would i go back to that page... thanks! Difference between Redirect en load-view - El Forum - 01-25-2013 [eluser]Harold Villacorte[/eluser] This would be the normal way of doing it: Code: function comment($id){ Then somewhere in the view file put something like this: Code: <?php if (validation_errors ()) : ?> Else redirect: Code: else { Then to echo the flashdata in the next view file: Code: <?php if ($this->session->flashdata('type_of_message')) : ?> Or something to that effect. Difference between Redirect en load-view - El Forum - 01-25-2013 [eluser]Harold Villacorte[/eluser] I might have posted some erroneous code here. Anyway just to not steer anyone in the wrong direction here is how I retrieve flashdata(). Obviously there is assignment in condition here, hard habit to break: In the controller: Code: $data = array(); In the view: Code: <?php if (isset ($message_success)) : ?> |