Processing forms - redirecting/passing to controllers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Processing forms - redirecting/passing to controllers (/showthread.php?tid=69937) |
Processing forms - redirecting/passing to controllers - vundo - 02-01-2018 Hello! I have created a controller, let's say Customer. I'm going to change some data in database using values passed by form. The method index() contains code to load view files, where form is generated using form helper (because I've enabled CSRF protection). The head of HTML form is PHP Code: form_open('customer/change_password'); Code: <form ... action="http://localhost/customer/change_password" method="POST" /> The problem is, that the website loads pages in this sequence: index -> user fills the form and submits -> redirects to change_password -> redirects to index How can I process the form in much more elegant way? I mean: index -> filling and submitting the form -> reload to index with status message The forms in CI are a nightmare for me . Here is my change_password PHP Code: public function change_password() RE: Processing forms - redirecting/passing to controllers - Elias - 02-01-2018 Hello! You can check passing 'submit' to index() method. If form was submitted, value of submit button will be passed to your controller. |