How to submit a page to the same controller in CodeIgniter

Imagine you have a view with a <FORM> that need to submit to the same controller class. Probably you don’t want to hardcode the action attribute of your form nor leaving it in blank.

Using PHP_SELF could be a possible approach. However, since $_SERVER[‘PHP_SELF’] is a PHP server variable (nothing to do with CodeIgniter), you may encounter some problems with different environments.

So, why not to use the built-in CodeIgniter URI library? My solution to this problem is the following. Use $this->uri->uri_string() in conjunction with site_url().

Here is a simple example:



Related searches:

  • codeigniter submit
  • codeigniter submit controller view
  • codeigniter $server[\php_self\]
  • submit codeigniter
  • how to resubmit the page to the same controller
  • controller in same page codeigniter
  • codeigniter submit to same page
  • codeigniter submit to different controller
  • codeigniter form helper submit to same page
  • codeigniter $_server[php_self
  1. Istvan says:

    It seems that the example are missing on this page.

  2. admin says:

    Yes, you are right, for some reason this post has something missing. I’ll try to complete it for you again. Thanks and sorry for the inconvenience.

  1. There are no trackbacks for this post yet.

Leave a Reply