I think you doing somthing wrong , it should work.
first check if it is bringing the right value. like is u put word category then see the word you type is geting there by using echo "$var"; command.
if you getting right value value. then try both way and use like this
if($var=="") { echo "print empty"; }
else { echo "print value"; }
and also try other way round
like if($var!= ""){ echo ....................
hope this should work
otherwise use javascript. javascript is fast and quicker because use on client side.