maxxd Posted October 6, 2019 Share Posted October 6, 2019 Hi y'all. So I'm currently working a project in CodeIgniter and I can't get the frigging thing to pass data from a form. At all. My autoload.php: $autoload['helper'] = [ 'text', 'form', 'url', ]; Here's the view code: <header> <div> <?php print form_open('/location/change', ['id'=>'location']); print form_label('Location', 'locations'); print form_dropdown('locations', $locations, (!empty($_SESSION['location'])) ? $_SESSION['location'] : ''); print form_submit('change_location', 'Change'); print form_close(); ?> </div> </header> The route: $route['location/change']['post'] = 'location/change'; And the controller code: class Location extends CI_Controller{ public function change(){ $this->output->enable_profiler(true); $vars = $this->input->post(); print("<pre>".var_export($_POST, true)."</pre>"); print("<pre>".var_export($vars, true)."</pre>"); } } The output: array ( ) array ( ) WTF? This is quite literally the simplest thing to do - I just want to pass data... Any ideas why it's not working? Quote Link to comment https://forums.phpfreaks.com/topic/309339-codeigniter-and-form-data/ Share on other sites More sharing options...
requinix Posted October 6, 2019 Share Posted October 6, 2019 Confirm that the <form> is method=POST, and that your browser is POSTing data to the script (using its developer console). And that there isn't somehow a redirect happening. Quote Link to comment https://forums.phpfreaks.com/topic/309339-codeigniter-and-form-data/#findComment-1570368 Share on other sites More sharing options...
maxxd Posted October 7, 2019 Author Share Posted October 7, 2019 I still don't know what the issue was - another form on the same page worked fine. I ended up refactoring to use text links instead of a drop-down and got it working. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/309339-codeigniter-and-form-data/#findComment-1570401 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.