CodeIgniter POST Variables

Does anyone know why:

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

Will CI write output variables for $ _POST, but NOT for $ this-> input-> post ();?

I use $ this-> input-> post () and work on the search page elsewhere on the site ... but on this page it doesn’t work .. here is 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 - - , ?

+5
3

, , XSS CSRF, ( ) Paypal, .

CodeIgniter, , CSRF ( config hook).

, POST, .

, $this->input->post()? , CI2.1 $this->input->post(), , post, ala:

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

+4

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

The only thing I can think of right now is that you might not have loaded the form helper, but I'm not sure if it is used for this. you can do it in/config/autoload.php

For example, I have this:

$autoload['helper'] = array('url', 'form', 'html', 'site_helper', 'upload_helper');

you can also load it into your function as follows:

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

All Articles