hno Posted January 24, 2010 Share Posted January 24, 2010 How should use it.I mean if I write: echo $_SERVER['HTTP_REFERRER'] It will return what his/her has been search in google? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/189592-how-to-use-_serverhttp_referrer/ Share on other sites More sharing options...
oni-kun Posted January 24, 2010 Share Posted January 24, 2010 No. It will return the last page they were on (in some cases, google). Maybe you should look at what a referrer is, you obviously don't know. Quote Link to comment https://forums.phpfreaks.com/topic/189592-how-to-use-_serverhttp_referrer/#findComment-1000717 Share on other sites More sharing options...
Daniel0 Posted January 24, 2010 Share Posted January 24, 2010 That could easily work. Just check if the referrer is from Google's result page. Quote Link to comment https://forums.phpfreaks.com/topic/189592-how-to-use-_serverhttp_referrer/#findComment-1000743 Share on other sites More sharing options...
hno Posted January 24, 2010 Author Share Posted January 24, 2010 That could easily work. Just check if the referrer is from Google's result page. Thanks for your reply Please give me an example of the usage . Is it just enough:echo $_SERVER['HTTP_REFERRER'] ; Thanks Quote Link to comment https://forums.phpfreaks.com/topic/189592-how-to-use-_serverhttp_referrer/#findComment-1000746 Share on other sites More sharing options...
Daniel0 Posted January 24, 2010 Share Posted January 24, 2010 Well, say I'm at http://www.google.com/search?q=php+help (Google search results for "php help") and I follow a link to PHP Freaks. If I do echo $_SERVER['HTTP_REFERRER'];, I'll just get http://www.google.com/search?q=php+help back. Whether that's "enough" is up to yourself of course. Consider this example: <?php $ref = 'http://www.google.com/search?q=php+help&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:official&client=firefox-a'; $components = parse_url($ref); if (preg_match('#^(?:www\.)?google(\.[a-z]+){1,2}$#i', $components['host']) && $path == '/search') { parse_str($components['query'], $query); if (isset($query['q'])) { echo 'Google search query: ' . htmlentities($query['q']); } } Quote Link to comment https://forums.phpfreaks.com/topic/189592-how-to-use-_serverhttp_referrer/#findComment-1000752 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.