这个问题可能是重复的,但我找不到我正在寻找的确切答案。
我有两个表单和两个 Controller 。
我想将数据输入到第一个 Controller View 中。在该页面上将数据提交到第二个 Controller 并将其显示在该 Controller View 上。
现在我尝试将表单输入数据插入 Controller 中的数组中,然后将其作为 View 中的普通变量进行访问,但没有成功。
我的第一种形式的 Controller
function new_order_details()
{
$this->load->view('sales/new_order_details');
}
我的输入表单 View :new_order_details'
<form id="sales_order_details" action="/sales/new_blank_order_lines" method="post">
<input type="text" id="customer" />
<input type="submit" name="blank_order" id="blank_order" value="Continue">
</form>
我的第二种形式的 Controller
function new_blank_order_lines()
{
$data = array(
'customer' =>$this->input->post('customer')
);
$this->load->view('sales/new_blank_order_lines',$data);
}
以及我想要显示数据的 View
<?php echo "--".$customer."--"; ?>
上面的输出是变量 $customer 为空。
任何想法将不胜感激。
感谢和问候。
最佳答案
它是空的,因为您没有为 View 文件中的客户输入字段提供名称参数。
编写html如下
<input type="text" id="customer" name="customer" />
关于arrays - Codeigniter - 将表单输入信息传递给 Controller 并将其显示在下一个 View 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15432403/