CodeIgniter POST变量 [英] CodeIgniter POST variables

查看:46
本文介绍了CodeIgniter POST变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道为什么:

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
    }
}

将在CI中回显$ _POST的发布变量但不是$ this-> input-> post();?

Will echo post variables in CI for $_POST but NOT for $this->input->post();?

我有$ this-> input-> post()正在使用,并且正在网站其他位置的搜索页面上工作...但是在此页面上,它不起作用.这是我的表格...

I've got $this->input->post() in use and working on a search page elsewhere in the site... but on this page, it's not working.. here's my form...


<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有人发现我显然很愚蠢的东西吗?

It's mental ;-p Anyone spot anything obviously stupid I'm missing?

推荐答案

您很可能已启用XSS或CSRF,它将禁止(在这里猜测)贝宝(Paypal)将这些详细信息还给您.

You most likely have XSS or CSRF enabled and it will prohibit (guessing here) Paypal to get those details back to you.

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

This is typical of CodeIgniter, and there are some work arounds like excluding CSRF for certain controllers (via config or hook).

如果您提供有关 POST 来自何处的更多详细信息,我可以清楚地回答.

If you give some more details on where the POST is coming from I can answer a bit clearly.

修改

可能是您错误地调用了 $ this-> input-> post()吗?我知道CI2.1添加了对 $ this-> input-> post()的支持以返回完整数组,但是直到这一点,您必须显式定义所需的post变量ala:

could be that you are calling $this->input->post() incorrectly? I know that CI2.1 added support for $this->input->post() to return the full array, but until this point you had to explicitly define the post variable you wanted ala:

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

这篇关于CodeIgniter POST变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆