Re: getting query string from referer website
| From: | Curt Zirzow | Date: | Mon, 28 Jun 2004 22:24:12 +0000 |
| Subject: | Re: getting query string from referer website | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189193@lists.php.net to get a copy of this message | ||
* Thus wrote I.A. Gray:
> Hi all,
>
> When I use the $_SERVER to get a query string it doesn't ever seem to return
> me anything:
>
> $queryy = $_SERVER['QUERY_STRING'];
>
> In my webstats script, 790 are blank and 2 give the value of "loc=uk" and
> "currentID=6" - not very satisfactuary!
>
> Why is this happening? Could I get the search string from the referer web
> site? It sounds like a bit of a faff, but is this what I have to do?
The referer and its query string are in:
$_SERVER['REFERER']
You'll have to substr() the strpos() of ? to get the query sting.
>
> Say a referer website is
>
> http://www.google.co.uk/search?q=web+design+for+performers&ie=UTF-8&hl=en&me
> ta=
>
> is there a good way of getting the query string "web design for performers"
> ?
>
> for Yahoo it is different:
>
>
> http://search.yahoo.com/search?p=biography+examples&ei=UTF-8&fr=fp-tab-web-t
> &n=20&fl=0&x=wrt
>
> the search string is followed by "p="
Once you get the query string parsed out of the referer you can
then use that string to pass to parse_str()...
parse_str($query, $queryparts);
$queryparts['q'] // the search term from google search
$queryparts['p'] // the search term from yahoo search
and if $queryparts['btnI'] == "I'm Feeling Lucky" make sure you
keep note of that 'q' search term :)
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!