Archive for the ‘uri’ tag
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:



