嘿伙计们只是想把一些东西传递给我的控制器。使用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>
答案 0 :(得分: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