CodeIgniter Forums
What I must do to add "CSFR prevention field" to my forms? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: What I must do to add "CSFR prevention field" to my forms? (/showthread.php?tid=54586)



What I must do to add "CSFR prevention field" to my forms? - El Forum - 09-15-2012

[eluser]frankabel[/eluser]
Hi,

In User Guide one can read

Quote:The first function is provided by the form helper and renders the form element and adds extra functionality, like adding a hidden CSFR prevention field. The latter is used to report errors related to form validation.

at http://ellislab.com/codeigniter/user-guide/tutorial/create_news_items.html

My question is, what I must do to get the cited "CSFR prevention field" to my form? I uses "form_open()" function but not attribute or field is added to my form.

Thanks in advanced
Frank


What I must do to add "CSFR prevention field" to my forms? - El Forum - 09-15-2012

[eluser]daparky[/eluser]
You can enable csrf protection by opening your application/config/config.php file and setting this:

$config['csrf_protection'] = TRUE;
If you use the form helper the form_open() function will automatically insert a hidden csrf field in your forms.


What I must do to add "CSFR prevention field" to my forms? - El Forum - 09-15-2012

[eluser]skunkbad[/eluser]
If you plan to use ajax, you will need to get the value of that token and send it along with your ajax request.


What I must do to add "CSFR prevention field" to my forms? - El Forum - 09-15-2012

[eluser]frankabel[/eluser]
Thanks you all for your useful replies.