RockyMtnHi Posted February 25, 2011 Share Posted February 25, 2011 When you do a search at (right sidebar): http://ourneighborhooddirectory.org the $_GET result is always blank. The site is hosted at Bluehost and this is a Wordpress site. You can see the result of the query because I write them out. Here is the form code: <form method="get" action="http://ourneighborhooddirectory.org/search-results/" > Search the Directory: <input type="text" name="srch"/> <input type="submit" value="Search" /> </form> Here is the PHP code on the action page: <?php $srchVal = $_GET["srch"]; echo $_GET['srch']; echo "------------ ". $srchVal." ------------"; print_r($_GET); echo $_SERVER['QUERY_STRING']; ?> Any ideas on why $_POST and $_GET always return blank? Thanks for the help... Quote Link to comment Share on other sites More sharing options...
samoht Posted February 25, 2011 Share Posted February 25, 2011 try adding a value="" to your text input Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 I added it but it didn't work (I had it in there before but removed it in testing). The code is now: <form method="get" action="http://ourneighborhooddirectory.org/search-results/" > Search the Directory: <input type="text" value="" name="srch"/> <input type="submit" value="Search" /> </form> Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 I also changed the php to: $srchVal = $_GET["srch"]; echo $_GET['srch']; echo "------------ ". $srchVal." ------------"; print_r($_GET); var_dump($_GET); echo $_SERVER['QUERY_STRING']."<br/><br/><br/>"; Quote Link to comment Share on other sites More sharing options...
samoht Posted February 25, 2011 Share Posted February 25, 2011 What does the url look like on the action page? Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 http://ourneighborhooddirectory.org/search-results/?srch=window Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 25, 2011 Share Posted February 25, 2011 Change the action in the form to: <form method="get" action="search-results/" > and add <?php echo '<pre>' . print_r($_GET,true) . '</pre>'; echo '<pre>' . print_r($_SERVER,true) . '</pre>'; ?> to the search-results script. Ken Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 I added all of that code: http://ourneighborhooddirectory.org/search-results/?srch=window but no joy. Note that the /3.php file is included in the action page. Quote Link to comment Share on other sites More sharing options...
samoht Posted February 25, 2011 Share Posted February 25, 2011 so what page is the form on? 3.php ?? Quote Link to comment Share on other sites More sharing options...
mattal999 Posted February 25, 2011 Share Posted February 25, 2011 http://ourneighborhooddirectory.org/3.php?srch=hi Yeah, there's probably some kind of problem with the server's configuration. Are you using any .htaccess rules? Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 I did have some .htaccess rules for redirects. I removed them and tested again and the Wordpress page still doesn't fetch the $_Get variables. Here is the code inside of Wordpress: http://ourneighborhooddirectory.org/search-results/?srch=window Here is the same code that works outside of Wordpress: http://ourneighborhooddirectory.org/3.php/?srch=window Somehow Wordpress is filtering out the $_GET values. Quote Link to comment Share on other sites More sharing options...
RockyMtnHi Posted February 25, 2011 Author Share Posted February 25, 2011 Fixed it! The Wordpress Inline PHP plugin was at the center of it. I just used an include between the <exec></exec> tags and that stripped out the $_GET['var'] values. When I placed the actual code in the file that was included the values were passed through. The application is a custom database application that is a directory of businesses servicing high-end neighborhoods in the Denver area. The search capability needed to pull specific listings that were searched for so I had to create the custom search capability for the site. I also went the extra step of highlighting all of the search terms. Here is the category page: http://ourneighborhooddirectory.org/homeowner-recommended-neighborhood-service-guide/neighborhood-service-guide-categories/ Here is every listing: http://ourneighborhooddirectory.org/homeowner-recommended-neighborhood-service-guide/recommended-service-guide-listings/ Do a search using the right sidebar search box. Search for something like 80210, floor, carpet, window, or jack. All 3 of these pages are custom PHP embedded into our Wordpress site. Thanks for the help... Quote Link to comment 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.