tags:

views:

33

answers:

3

On one page of my website, I am getting a lot of visitors from a specific keyword. I want to display a message for only those visitors coming from that search keyword. How can I check if the user is coming from the search engine / that keyword?

+1  A: 

$_SERVER['HTTP_REFERER'] should give you the data that you are looking for. You can run it against a regular expression like \?.+foo if 'foo' is the keyword that you are looking for. the regular expression is not super reliable as it will match any referring site with the keyword in the query string but it should be good enough. It does have the advantage of matching any search engine and not just focusing on a set list as most scripts of this type do.

aaronasterling
+1  A: 

Parse $_SERVER['HTTP_REFERER'] but bear in mind that it is optional whether a browser supplies this information. Also, as user submitted data, it should be considered subject to tampering.

C.

symcbean
+1  A: 

you need to parse the $_SERVER['HTTP_REFERER']

this link explain good how to parse it

http://www.stevenyork.com/tutorial/how_to_get_search_engine_referal_keywords_using_php

Haim Evgi