【问题标题】:receive post information with codeigniter使用 codeigniter 接收帖子信息
【发布时间】:2013-04-03 14:18:18
【问题描述】:

我有一个带有数据的订单。在提交时调用控制器函数new_blank_order_summary

语法是:

    function new_blank_order_summary() 
  {
      echo "orderlines: ".$this->input->post(orderlines);
      echo "customer: ".$this->input->post('customer');
      echo "period: ".$this->input->post('period');
      echo "creditlimit: ".$this->input->post('creditlimit');   

      $this->load->view('sales/new_blank_order_summary');

  }

我无法让帖子信息显示或回显?我输入的姓名和 ID 是 orderlines,但没有正确发布或接收。

为“愚蠢”的问题道歉。

欢迎任何建议。

HTML

<form id="sales_blank_order_details" action="/sales/new_blank_order_summary" method="post">


            <table >
                <tr><td>Customer</td><td>Period</td><td>UoM</td><td>Credit Limit</td><td>Balance</td><td>New Balance</td><td>Order Lines</td><td>Round to Bundle</td></tr>
                    <tr><td>
            <input type="text" name="customer" id="customer" value="<?php echo $customer; ?>" disabled>
               </td><td>
            <input type="text" name="period" id="period" value="<?php echo $period." to ".$newperiod; ?>" disabled>
               </td><td>
            <input type="text" name="buom" id="buom" value="<?php echo $buom; ?>" disabled>
               </td><td>
            <input type="text" name="creditlimit" id="creditlimit" value="<?php echo $creditlimit['creditlimit']; ?>" disabled>
           </td><td>
            <input type="text" name="currentbalance" id="currentbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
           </td>
           <td>
            <input type="text" name="newbalance" id="newbalance" value="<?php echo $creditlimit['currentbalance']; ?>" disabled>
           </td><td>
            <input type="text" name="orderlines" id="orderlines" value="1" disabled>
           </td><td>
            <input type="checkbox" name="rounduptobundle" id="rounduptobundle" checked>
           </td></tr></table>

<input type="submit" name="blank_order_lines" id="blank_order_lines" value="Save Order and Proceed">

</form>

这些帖子都不是控制器输出的。

【问题讨论】:

  • orderlinesswith double s?
  • 对不起 Mudshark,错字:-)
  • html表单是什么样子的?
  • 添加到问题中,谢谢 Mudshark
  • 为什么所有输入字段都被禁用了。并尝试查看 html 表单是否正在获取您发送的所有数据。

标签: codeigniter post


【解决方案1】:

您已禁用 orderlines 文本输入字段,这就是它不会被发布的原因。删除disabled,它会出现在$this-&gt;input-&gt;post()中。

【讨论】:

  • 所以禁用的输入不会被发布?如何阻止用户编辑它们并仍然发布它们?它们需要显示,所以隐藏不会起作用。
  • 您可以使用name="orderlines" value="1" 添加一个隐藏字段,该字段将显示在帖子中 - 在这种情况下,(禁用的)可见文本字段不需要name,它只是作为视觉反馈存在给用户。
【解决方案2】:

提交按钮的名称和值是什么。通常我的提交按钮的名称是 name="submit",值是 value="submit"。然后我尝试 $this->input->post('submit')=='submit'。在你的 if 条件下试试这个。我希望它会奏效。祝你好运。

【讨论】:

  • 感谢 eddard,if 语句正在工作,但订单行的帖子却没有。我可以在条件内放置一个echo 'test',它会正确显示。再次感谢。
【解决方案3】:
function new_blank_order_summary() 
{
      echo "orlderlines: ".$this->input->post('orderlines');
      echo "customer: ".$this->input->post('customer');
      echo "period: ".$this->input->post('period');
      echo "creditlimit: ".$this->input->post('creditlimit');   

      $this->load->view('sales/new_blank_order_summary');

}

请尝试此代码。我没有更改其中的一行。只有我把单引号放在第 3 行。并且,更改它的变量名是错误的,所以我更改了它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多