Simple Search: Passing Form Variable to URI Using CodeIgniter

前端 未结 5 1206
旧巷少年郎
旧巷少年郎 2021-02-06 17:49

I have a search form on each of my pages. If I use form helper, it defaults to $_POST. I\'d like the search term to show up in the URI:

http://examp         


        
5条回答
  •  不知归路
    2021-02-06 18:09

    Check out this post on how to enable GET query strings together with segmented urls.

    http://codeigniter.com/forums/viewthread/56389/#277621

    After enabling that you can use the following method to retrieve the additional variables.

    // url = http://example.com/search/?q=text
    $this->input->get('q');
    

    This is better because you don't need to change the permitted_uri_chars config setting. You may get "The URI you submitted has disallowed characters" error if you simply put anything the user enters in the URI.

提交回复
热议问题