curiosity4834
curiosity4834

Reputation: 73

Using codeigniter input library in safe

Genereally I'm using codeigniter input library like that =>

$insert = $this->input->post();

I wonder is it safe or must I use like that? =>

$name = $this->input->post('name');
$gsm = $this->input->post('gsm');
$insert = array(
  'name' => $name,
  'gsm' => $gsm
);

Upvotes: 0

Views: 311

Answers (1)

Vikas Arora
Vikas Arora

Reputation: 1666

If you want to make the POST method safe, then also provide second parameter:

For your first method:

$this->input->post(NULL, TRUE);

This will return all the POST items with XSS filter.

...And if you want to use second method:

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

This will return the POST item with the name of 'input_field_name' with XSS filter applied.

You can read more about codeigniter input class and XSS security HERE.

Upvotes: 1

Related Questions