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 CRUD Operations with PHP Creating Records Accepting User Data

Henry Lin
Henry Lin
11,636 Points

Why do we need filter category if it's just a selection list?

$category = trim(filter_input(INPUT_POST,'category',FILTER_SANITIZE_STRING));

why do we need filter this if we don't need users to type anything ?

1 Answer

It is possible to fake a post request to a website. This means that anyone can put something into your post handler, even if it is not in the drop-down box. You filter it to improve security and prevent any issues.