Jump to content

$_Get Always Returns Blank


RockyMtnHi

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/228812-_get-always-returns-blank/
Share on other sites

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>

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

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.

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.