有人知道原因:
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();?
我已经使用了$ 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任何人发现任何明显愚蠢的东西我都错过了吗?
3 回答
您很可能已启用XSS或CSRF,它将禁止(猜测此处)Paypal将这些详细信息发回给您 .
这是典型的CodeIgniter,并且有一些解决方法,例如为某些控制器排除CSRF(通过配置或挂钩) .
如果你提供一些关于
POST
来自哪里的更多细节,我可以清楚地回答一下 .edit
可能是你错误地调用
$this->input->post()
?我知道CI2.1增加了对$this->input->post()
的支持以返回完整的数组,但是在此之前你必须明确定义你想要ala的post变量:$user = $this->input->post('username');
我解决了这个问题,排除了针对该特定方法的CSRF保护
您可以在application / config / config.php中添加此代码
我现在唯一能想到的就是你可能没有加载表单助手,但我使用了'm not sure if it' . 你可以在
/config/autoload.php
这样做我举例说:
你也可以在你的函数中加载它,如下所示: