将形式变量传递给控制器


passing in form variables to controller

嘿,伙计们正试图把一些东西传给我的控制器。使用下面的形式的代码点火器实际上并没有把我重定向到任何地方,怎么了?

我的第二个问题是,如何在控制器中获取数据。。?

$data = $this->input->$post('search'); 

<?php
$options = array(
                  'small'  => 'Small Shirt',
                  'med'    => 'Medium Shirt',
                  'large'   => 'Large Shirt',
                  'xlarge' => 'Extra Large Shirt',
                );
$shirts_on_sale = array('small', 'large');
echo form_dropdown('shirts', $options, 'large');
?>
 <form  action="<?php echo site_url('home/id_search');?>" method="post"><input type="submit" value="submit" id="" name="" >
</form>

您将表单打开标记放错了位置,do:

 <form  action="<?php echo site_url('home/id_search');?>" method="post">
<?php
$options = array(
                  'small'  => 'Small Shirt',
                  'med'    => 'Medium Shirt',
                  'large'   => 'Large Shirt',
                  'xlarge' => 'Extra Large Shirt',
                );
$shirts_on_sale = array('small', 'large');
echo form_dropdown('shirts', $options, 'large');
?>
<input type="submit" value="submit" id="" name="btnSubmit" />
</form>
And to get POST date in you controller, do:
$data = $this->input->post('shirts'); //for getting shirts form field value