Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Adding a Basic Form Validating Form Data

question about filter_input() func

Hey.

anybody can clear what is the use of the filter_input?

lets take for exmaple this line:

<?php
filter_input(INPUT_POST,"username",FILTER_SANITIZE_STRING)
?>

as far as i see this func let us filter a input from the form with advanced settings. for exmaple if i want to filter an email then i have the "FILTER_SANITIZE_EMAIL" which Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].

we used "INPUT_POST" because we submit our form with POST method?

The second variable according the docs is for "Name of a variable to get.", we will always would want to put the variable in the "name" tag in our form inputs? only the values in the names tag are being sent to the servers

any help will be appreciated :]

2 Answers

Steven Parker
Steven Parker
210,131 Points

I'm not sure what you're asking, you seem to have described what this code is doing.

For more details, see the PHP manual page on filter-input.