Jump to content

CodeIgniter and form data

Recommended Posts

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'] = [

Here's the view code:

			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();

The route:

$route['location/change']['post'] = 'location/change';

And the controller code:

class Location extends CI_Controller{
   public function change(){


    $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?

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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!

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.