Some use PHP like suggested:
[
warriorforum.com...]
and man websites use hidden values in the form:
<input type="hidden" name="keyword" value="<?php echo $_COOKIE['keyword']; ?>" />
Replacing "keyword" with your actual field and cookie names
<?php
session_start();
if(!$_SESSION['referer'])
{
$URL = $_SERVER['HTTP_REFERER'];
//first see if the url contains google
if(($pos = strpos($URL, 'google'))||($pos = strpos($URL, 'msn'))||($pos = strpos($URL, 'bing')))
{
// get everything after the q=
$query=strstr($URL, "q=");
$array=explode('&', $query); // get rid of everything after the first &
foreach ($array as $param)
{
if ($param{0} == 'q') // its q, so it's either google or msn/bing
{
$word_string = substr($param, 2); // strip q=
}
}
$keywords = str_replace('"', '', urldecode($word_string)); //clean keywords, get rid of the + and quotes
$_SESSION['referer'] = $URL; // set the url in the session
if($keywords){ $_SESSION['keywords'] = $keywords; } // set the keywords in the session
}
elseif($pos = strpos($URL, 'yahoo'))
{
// get everything after the p=
$query=strstr($URL, "p=");
$array=explode('&', $query); // get rid of everything after the first &
foreach ($array as $param)
{
if ($param{0} == 'p') // its a p so its yahoo
{
$word_string = substr($param, 2); // strip the p=
}
}
$keywords = str_replace('"', '', urldecode($word_string)); //clean keywords, get rid of the + and quotes
$_SESSION['referer'] = $URL; // set the url in the session
if($keywords){ $_SESSION['keywords'] = $keywords; } // set the keywords in the session
}
else
{
//not one of the 3 search engines so just hold the URL
$_SESSION['referer'] = $URL;
}
}
?>