I’m using the Codeigniter framework and am in the process of creating a registration form. The registration process is completed in multiple steps- for which I’ve created different views.
What I have a problem with is making the controller read that I’ve continued to a new step. I tried solving this by posting the form to index.php/controller/2 but as I reach the page I get a 404 error stating
The page doesn’t exist.
I’ve loaded the URI helper so I don’t quite understand where the problem lies.
All help is very much appreciated
By submitting the form to
index.php/controller/2you’re effectively sayingI suspect you don’t have a method named 2, and you want to pass two as an argument to a method which handles step 1. Which might be
/controller/registeror similar.You need to submit your form to
index.php/controller/method/2and insidemethodcheck which step you’re on using$this->uri->segment(2)Ideally, create a different method for each step as it’ll better separate the logic. For example
Which will allow you to call
index.php/registration/step_1/andindex.php/registration/step_2/for example.You may also wish to use the Session class to set variables indicating which stages are complete to prevent people skipping to other stages by typing in the URL.