CI_Input::post()

post([$index = NULL[, $xss_clean = NULL]])

Parameters:
  • $index (mixed) – POST parameter name
  • $xss_clean (bool) – Whether to apply XSS filtering
Returns:

$_POST if no parameters supplied, otherwise the POST value if found or NULL if not

Return type:

mixed

The first parameter will contain the name of the POST item you are looking for:

$this->input->post('some_data');

The method returns NULL if the item you are attempting to retrieve does not exist.

The second optional parameter lets you run the data through the XSS filter. It’s enabled by setting the second parameter to boolean TRUE or by setting your $config['global_xss_filtering'] to TRUE.

$this->input->post('some_data', TRUE);

To return an array of all POST items call without any parameters.

To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean TRUE.

$this->input->post(NULL, TRUE); // returns all POST items with XSS filter
$this->input->post(NULL, FALSE); // returns all POST items without XSS filter

To return an array of multiple POST parameters, pass all the required keys as an array.

$this->input->post(array('field1', 'field2'));

Same rule applied here, to retrive the parameters with XSS filtering enabled, set the second parameter to boolean TRUE.

$this->input->post(array('field1', 'field2'), TRUE);
doc_CodeIgniter
2016-10-15 16:31:39
Comments
Leave a Comment

Please login to continue.