Your 2nd script works fine but need small correction on empty search. If a user did not enter anything in the search box and press search button he should get a message saying you haven't enter anything in the search box.

Can it be possible and this will be last correction.