input->get('var_name') - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: input->get('var_name') (/showthread.php?tid=38453) |
input->get('var_name') - El Forum - 02-08-2011 [eluser]ELRafael[/eluser] Hy Guys, My view. It's a simple search form current_url() = http://site.local/news/index Code: <?php echo form_open( current_url(), 'method="get"' ); ?> My Controller (news, function index()) Code: $search_term = $this->input->get('search_term'); Result: Always bool(false) The url "submited" http://site.local/news/index?ci_csrf_token=big_encode_number&search_term=Acentuação&..... My config.php Code: $config['uri_protocol'] = "AUTO"; I'm using CodeIgniter 2.0 under MAMP enviroment Can anyone help me? Before any anwser, I know if I change the form's method to post and try to get the value using $this->input->post('search_term') will work fine. But I really wanna use GET method, not POST. I still belive that POST method is for CHANGING ACTIONS (new user, edit data, ....) Thanks a lot input->get('var_name') - El Forum - 02-08-2011 [eluser]CroNiX[/eluser] Haven't messed with it, but you might want to try setting: $config['enable_query_strings'] = TRUE; $config['uri_protocol'] = "QUERY_STRING"; input->get('var_name') - El Forum - 02-08-2011 [eluser]ELRafael[/eluser] Still no donut for me :blank: Code: $config['enable_query_strings'] = TRUE; Now the problem is another!! When I open the page, and I can't submit anymore. Click in the submit button and come back to main page (base_url()). I just wanna use $this->input->get('var_name') :down: I'm starting to think that CI can't work with query strings input->get('var_name') - El Forum - 02-08-2011 [eluser]Eric Barnes[/eluser] I think you want this using ci2 reactor: Code: $config['allow_get_array'] = TRUE; input->get('var_name') - El Forum - 02-09-2011 [eluser]ELRafael[/eluser] Eric, still don't work. config.php Code: //allow_get_array is in the TOP of file My form Code: <?php echo form_open(current_url(), 'method="get"'); ?> http://site.local/news/index?ci_csrf_token=encoded&texto=asdasd&.... My controller Code: var_dump($this->input->get('search_term')); I'm not using CodeIgniter Reactor. I just did the download from codeigniter.com I'll try to implement a Javascript (JQuery) solution. Code: $('form#my_form_id').submit(function(e) { I still don't know why $this->input->get('var_name') returns false all the time. input->get('var_name') - El Forum - 02-09-2011 [eluser]Eric Barnes[/eluser] Try it manually: http://yousite.com/controller/method?searchterm=test Then in controller: Code: var_dump($this->input->get('searchterm')); input->get('var_name') - El Forum - 02-11-2011 [eluser]abedzilla[/eluser] You must enable query string and set the uri_protocol to PATH_INFO Code: $config['uri_protocol'] = "PATH_INFO"; |