Jump to content

CodeIgniter and form data


maxxd

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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