Pikachu2000 Posted January 12, 2011 Share Posted January 12, 2011 That ain't gonna happen unless you change the logic of that script so that the query runs before that point. Quote Link to comment https://forums.phpfreaks.com/topic/223764-creating-a-search-form/page/2/#findComment-1158217 Share on other sites More sharing options...
jirble2 Posted January 12, 2011 Author Share Posted January 12, 2011 Ok, I'll look into that, but what about the problem of the blank and spacebar search. I also discovered that you can only search one word or else the search won't return any results. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/223764-creating-a-search-form/page/2/#findComment-1158323 Share on other sites More sharing options...
Pikachu2000 Posted January 12, 2011 Share Posted January 12, 2011 If you want the search query to run only if something has been entered, all you need to do is check that the field isn't empty after trimming whitespace. $_POST['search_term'] = trim($_POST['search_term']); if( empty($_POST['search_term']) ) { // allow the query to run } else { // don't allow the query to run, display error, or send back to search form, etc. } Quote Link to comment https://forums.phpfreaks.com/topic/223764-creating-a-search-form/page/2/#findComment-1158353 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.