CodeIgniter POST变量

Bee*_*tic 6 post codeigniter

有人知道原因:

class Booking extends Controller {

    function booking()
    {
        parent::Controller();
    }

    function send_instant_to_paypal()
    {
        print_r($_POST);
        echo '<hr />';
        print_r($this->input->post());
        echo '<hr />';
        $id_booking = $this->input->post('id_booking');
        $title = $this->input->post('basket_description');
        $cost = ($this->input->post('fee_per_min') * $this->input->post('amount'));
        echo $id_booking;
        echo $title
        echo $cost
    }
}
Run Code Online (Sandbox Code Playgroud)

将回显CI中的变量用于$ _POST但不用于$ this-> input-> post();?

我已经使用了$ this-> input-> post()并在网站的其他地方搜索了一个搜索页...但是在这个页面上,它不起作用..这是我的表格......

<form id="add_funds" action="' . site_url('booking/send_instant_to_paypal') . '" method="post">
<input type="text" name="amount" id="amount" value="" />
<input type="hidden" name="id_booking" id="id_booking" value="0" />
<input type="hidden" name="basket_description" id="basket_description" value="Adding Credit" />
<input type="hidden" name="fee_per_min" id="fee_per_min" value="' . $fee_per_min . '" />
<input type="submit" value="Add to basket" />
</form>

这是精神上的;-p任何人发现任何明显愚蠢的东西我都错过了吗?

Jak*_*kub 6

您最有可能启用了XSS或CSRF,它将禁止(在此处进行猜测)贝宝将这些详细信息还给您。

这是CodeIgniter的典型代表,并且有一些解决方法,例如排除某些控制器的CSRF(通过配置或挂钩)。

如果您提供有关其来源的更多详细信息POST,我可以清楚地回答。

编辑

可能是您打错电话了$this->input->post()吗?我知道CI2.1添加了$this->input->post()对返回完整数组的支持,但是直到此时,您必须显式定义所需的post变量ala:

$user = $this->input->post('username');

  • 我怀疑您将CI2.1文档(用户指南)与CI1.X版本混淆了,因此$ this-&gt; input-&gt; post()不会为您返回数组。在最新的更改日志中查看此处:http://codeigniter.com/user_guide/changelog.html (3认同)