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 trialMatt Corby
2,385 PointsTitle Special Chars are in ascii
When I send the email if I put a non-alpha in the title, like a ' for example, the email shows that as a #&39;
I'm pretty sure I can fix this using a different sanitizer for the filter_input function but i'm not sure which one...
Manansh Saxena
547 PointsAre you using FILTER_SANITIZE_EMAIL for title ?
It will be good if you paste the code snippets here.
Matt Corby
2,385 PointsYeah the FILTER_SANITIZE_EMAIL was the only one I could see that didn't change special chars to ascii.
Here's the code, I changed the filter for title back to string so it would go with the rest of the videos.
$name = trim(filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING));
$email = trim(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL));
$category = trim(filter_input(INPUT_POST, 'category', FILTER_SANITIZE_STRING));
$title = trim(filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING));
$format = trim(filter_input(INPUT_POST, 'format', FILTER_SANITIZE_STRING));
$genre = trim(filter_input(INPUT_POST, 'genre', FILTER_SANITIZE_STRING));
$year = trim(filter_input(INPUT_POST, 'year', FILTER_SANITIZE_STRING));
$details = trim(filter_input(INPUT_POST, 'details', FILTER_SANITIZE_SPECIAL_CHARS));
When I entered a ' in the title form the email would come out as #&39, the ascii value.
Matt Corby
2,385 PointsMatt Corby
2,385 PointsI used the FILTER_SANITIZE_EMAIL and that worked except it also gets rid of spaces, which is no good if a user puts in a title with more than one word. It seems there's no filter that just strips html tags...