Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

geoffrey
geoffrey
28,736 Points

Form validation, sanitize filter, Which filter to use and why ?

Hi Alena Holligan ,

I wanted to know, in the video about the simple form validation with PHP you show how to use the INPUT_POST function and the differents filters.

My question is really simple, why do you use the FILTER_SANITIZE_SPECIAL_CHARS on the details variable (Which contains information from the textarea, basically a string), where as for the input name you use the FILTER_SANITIZE_STRING filter.

Both are input sending a string to the server, both can have html tags or special chars, which one to use in which circumstance ? I looked at the PHP doc and can't see any reason to use one over the other.

Thank you in advance for your enlightment.