How do i page using forms with the Codeigniter framework? How do i page using forms with the Codeigniter framework? codeigniter codeigniter

How do i page using forms with the Codeigniter framework?


By submitting the form to index.php/controller/2 you're effectively saying

  • Load /application/controllers/Controller.php
  • Instantiate class Controller
  • Run Controller::2()

I 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/register or similar.

You need to submit your form to index.php/controller/method/2 and inside method check 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

class Registration {    function step_1() {}    function step_2() {}}

Which will allow you to call index.php/registration/step_1/ and index.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.