Ok, I have a lovely site with all elements split into many different php pages.
One of the sidebars is my searchbox - this works fine when I am on the page I am wanting to search - ie the maps page.
HOWEVER, when I am on another page that uses the search box (ie the homepage) how do I force it to open the maps/results page?
I know this is base level stupid, and the question really is:
how do I tell my form enquiry to open results on another page!?
A tricky situation for Google Maps and seach box
Moderator: General Moderators
-
noseyparker
- Forum Newbie
- Posts: 1
- Joined: Fri Jun 19, 2009 10:36 am
Re: A tricky situation for Google Maps and seach box
When someone hits search and starts your script, you can check the current URL and redirect via a header(location) call, but you'll need to pass a parameter to tell the search page to continue to execute your query.
Depending on the structure of your site you can try one of these $_SERVER variables
$REQUEST_URI
$PHP_SELF
$SCRIPT_NAME
for info see http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm
So check the url, then pass the user to your page url with a ?do=search tag so that when your user is redirected to your map page, the URL gets parsed and the search is executed without them having to hit search again.
header("Location: http://yourdomain.com/mappage.php?do=search");
Does this make sense? Maybe someone knows an easier way, but that's how I would try it.
FYI here is a little snippet of how to parse the URL line easily
Depending on the structure of your site you can try one of these $_SERVER variables
$REQUEST_URI
$PHP_SELF
$SCRIPT_NAME
for info see http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm
So check the url, then pass the user to your page url with a ?do=search tag so that when your user is redirected to your map page, the URL gets parsed and the search is executed without them having to hit search again.
header("Location: http://yourdomain.com/mappage.php?do=search");
Does this make sense? Maybe someone knows an easier way, but that's how I would try it.
FYI here is a little snippet of how to parse the URL line easily
Code: Select all
<?php
switch (@$_GET['do'])
{
case "search":
// display page, run search automatically
break;
default:
// normal call to page, display page
}
?>