![]() |
Form validation - 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: Form validation (/showthread.php?tid=42391) |
Form validation - El Forum - 06-06-2011 [eluser]Uplift[/eluser] I am new to CI and have went through the video tutorials, i want to expand on that by adding validation to the form. Now the method in the user guide and the method in the video is different. Code: function comment_insert() { If the form is VALID then it works fine. if the form is invalid it just refreshes the page and doesn't show the validation errors, i want the exact comments page and form to show, but with the error above it. I have this in my comments_view <?php echo validation_errors(); ?> Why is it not showing the val errors? Form validation - El Forum - 06-06-2011 [eluser]cideveloper[/eluser] First of all dont use $_POST, use $this->input->post Secondly in either case you are just redirecting to Code: 'blog/comments/'.$_POST['entry_id'] thus in both instances you will get the same result you can do something like this even though I dont think its the best way. Code: function comment_insert() { and in the view you would have Code: <?php echo $this->session->flashdata('message'); ?> Like I said, I dont think this is the best way. usually you should have the form being displayed using load view when the form_validation is false. Form validation - El Forum - 06-06-2011 [eluser]Uplift[/eluser] thanks i will give it a go. |