0

嘿,伙计们只是想将一些东西传递到我的控制器中。使用codeigniter,下面的表格实际上并没有将我重定向到任何地方,有什么问题?

我的第二个问题是如何简单地获取控制器中的数据..?

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

1 回答 1

2

您将表单开始标签放置在错误的位置,请执行以下操作:

 <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
于 2012-09-09T12:11:43.150 回答