任何人都知道原因:
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变量$ _POST 但不是$ this-&gt; input-&gt; post();?
我有 $ this-&gt; input-&gt; 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 有人发现任何明显愚蠢的东西我都错过了吗?
答案 0 :(得分:4)
您很可能已启用XSS或CSRF,它将禁止(猜测此处)Paypal将这些详细信息发回给您。
这是典型的CodeIgniter,并且有一些解决方法,例如为某些控制器排除CSRF(通过配置或挂钩)。
如果您提供一些有关POST
来自何处的详细信息,我可以清楚地回答一下。
修改强>
可能是您错误地调用了$this->input->post()
?我知道CI2.1增加了对$this->input->post()
的支持以返回完整的数组,但在此之前你必须明确定义你想要ala的post变量:
$user = $this->input->post('username');
答案 1 :(得分:2)
我通过排除针对该特定方法的CSRF保护解决了该问题
您可以在application / config / config.php
中添加此代码if(stripos($_SERVER["REQUEST_URI"],'/Booking/send_instant_to_paypal') === FALSE)
{
$config['csrf_protection'] = TRUE;
}
else
{
$config['csrf_protection'] = FALSE;
}
答案 2 :(得分:0)
我现在唯一能想到的就是你可能没有加载表单助手,但我不确定它是否被用于那个。
您可以在/config/autoload.php
我举个例子:
$autoload['helper'] = array('url', 'form', 'html', 'site_helper', 'upload_helper');
你也可以在你的功能中加载它,如下所示:
function send_instant_to_paypal()
{
$this->load->helper('form');
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
}