Use php to record keywords that users enter the website through search engines
To facilitate SEO, we need to record users' search keywords through common search engines. The following is the implementation code for accessing your website.
The Code is as follows:
$ Rfr = $ _ SERVER ['HTTP _ referer'];
// If (! $ Rfr) $ rfr = 'HTTP: // '. $ _ SERVER ['HTTP _ host'];
If ($ rfr)
{
$ P = parse_url ($ rfr );
Parse_str ($ p ['query'], $ pa );
$ P ['host'] = strtolower ($ p ['host']);
$ Arr_sd_key = array (
'Baidu. com' => 'word ',
'Google. com' => 'Q ',
'Sina .com.cn '=> 'word ',
'Sohu. com' => 'word ',
'Msn. com' => 'Q ',
'Bing. com' => 'Q ',
'2014. com' => 'Q ',
'Yahoo. com' => 'P'
);
$ Keyword = '';
$ Sengine = $ p ['host'];
Foreach ($ arr_sd_key as $ se => $ kwd)
{
If (strpos ($ p ['host'], $ se )! = False)
{
$ Keyword = $ pa [$ kwd];
$ Sengine = $ se;
Break;
}
}
$ SQL = "insert into visit_log (domain, key_word, ct )";
}