jigniter™

jQuery & CodeIgniter – Perfect combination for web application

How to submit a page to the same controller in CodeIgniter

2 comments

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:



No related posts.

Posted by admin

2009-07-17 at 11:23 am

Date Snippets Ideas

Tags: ,

2 Responses to 'How to submit a page to the same controller in CodeIgniter'

Subscribe to comments with RSS or TrackBack to 'How to submit a page to the same controller in CodeIgniter'.

  1. It seems that the example are missing on this page.

    Istvan

    17 Sep 09 at 6:51 am

  2. 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.

    admin

    17 Sep 09 at 9:55 am

Leave a Reply