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 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.