• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to customize $this->input->post()

[eluser]Colin Williams[/eluser]
It's not clearly stated.

Quote:The main advantage of using the provided functions rather than fetching an item directly ($_POST['something']) is that the functions will check to see if the item is set and return false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first.

Do you need that advantage in your case? No.

Quote:For the sake of simplicity in this example we're using $_POST directly. This is generally bad practice, and a more common approach would be to use the Input Class $this->input->post('title')

This is probably what you are referring to. Shame it was worded that way, because later we see:

Quote:Before accepting any data into your application, whether it be POST data from a form submission, COOKIE data, URI data, XML-RPC data, or even data from the SERVER array, you are encouraged to practice this three step approach:
1. Filter the data as if it were tainted.
2. Validate the data to ensure it conforms to the correct type, length, size, etc. (sometimes this step can replace step one)
3. Escape the data before submitting it into your database.

So, just xss_clean() all incoming data in your models and you will be fine using $_POST. Example model function:

function save($obj)
   $obj = xss_clean($obj);
   $obj = $this->_prep_obj($obj);
   // _prep_obj is a private method that removes unnecessary properties.
   // You could xss_clean in that function to keep this method clean.
   return $this->db->insert($this->table, $obj)

Messages In This Thread
How to customize $this->input->post() - by El Forum - 10-11-2009, 04:37 PM
How to customize $this->input->post() - by El Forum - 10-11-2009, 06:02 PM
How to customize $this->input->post() - by El Forum - 10-12-2009, 12:05 AM
How to customize $this->input->post() - by El Forum - 10-12-2009, 12:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.