• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating from 1.6.3 to 2.1.0 - getting validated POST data

I've been away from CI for a while, apologies if this is obvious.

I'm updating a site from CI 1.6.3 to 2.1.0

Getting POST data using the old validation class used something like:

$my_form_field = $this->validation->my_form_field;

With the replacement form_validation class is it sufficient to simply use:

$my_form_field = $this->input->post('my_form_field');

Should be okay, but you might want to read up on the guide:


Also check these ./application/config/config.php:
| Cross Site Request Forgery
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.

$config['csrf_protection']  = FALSE;
$config['csrf_token_name']  = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire']      = 7200;

[quote author="dallen33" date="1329072872"]Should be okay, but you might want to read up on the guide...[/quote]
Surprisingly, the guide does not show an example of using the POST data.

My assumption is that the method form_validation->run() reads and validates the POST data, and the method subsequently used to fetch the POST data is arbitrary. The old validation->run() also worked on the POST data, but using $this->validation->my_form_field validated the field again, and was deemed redundant.

I think it's safe to use $this->input-post(my_form_field) without fear of the reworked 2.1.0 code being any less robust than it's predecessor.

< : ) den

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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