PHP Code:
// Session to store your keyword
session_start();
session_register('keyword');
if(preg_match('/google|yahoo|msn|altavista/i', $parts['host']) && !empty($parts['query'])) {
}
$referer_query = '';
$referer_params = array('q','query','p','Q','Query','P');
if(!empty($_SERVER['HTTP_REFERER'])) {
$parts = parse_url($_SERVER['HTTP_REFERER']);
if(!empty($parts['query'])) {
parse_str($parts['query'], $query_params);
foreach($referer_params as $key) {
if(isset($query_params[$key])) {
$referer_query = $query_params[$key];
break;
}
}
}
}
if(!empty($referer_query)) {
$_SESSION['keyword'] = urlencode($referer_query);
}else{
// theres no keyword Bookmark?
$_SESSION['keyword'] = 'NULL';
}
You can then carry this over to your links page and call the session var
PHP Code:
// Links page
// Don't forget this
session_start();
// link example
$link = mysql_query("select link from tablename where id = '".$_GET['id']."'");
$l=mysql_fetch_assoc($link);
header('Location: '.$link.'&epi='.$_SESSION['keyword']);
exit();
Bookmarks