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 Enhancing a Simple PHP Application Adding Search: Controller & View Escaping Output Review

Vince Brown
Vince Brown
16,249 Points

code challenge Adding Search: Controller HELP!!

I dont know why it is not passing I keep on getting a bummer, but when i use the code below in my project it is working perfect and keeping the search term in the input field when a search term is entered

<input type="text" name="s" value="<?php if(isset($search_term)) {echo htmlspecialchars($search_term);} ?>" >

1 Answer

Scott Evans
Scott Evans
4,236 Points

Hey there Vince!

Unfortunately I couldn't identify exactly what you were doing wrong. I had a mess around with the code and manage to get it working and passing the challenge.

<input type="text" value="<?php if(isset($search_term)){echo htmlspecialchars($search_term);} ?>" name="s">

As you can see, the only different is i moved the "value" attribute before the "name".

Hope this helps! Scott.