Jump to content

Dynamic Landing Page


LegionSmith

Recommended Posts

Hi everyone,

 

I'm trying to create a dynamic landing page for a client of mine. My intention here is this. Take a single template page that loads the end users search engine search query's into the appropriate spots on the landing page. As in, someone looks for "Rentals Denver Colorado". when they click on the link for our site in Google their search terms are passed through a script, compared against our database of cities and states, matched and displayed on the landing page. There is more that will happen but my problem here is in the matching. I've gotten the script to where it pulls the search query words out, now I need to figure out how to match that against mysql db, drop any non matching words, and make the matched words available for use on the landing page.

 

here's what I have so far, this pulls the query words out as an array, splits the words then makes them a single string.

 

global $referer, $engine, $query, $query_array, $query_terms;

// Setup
$referer     = $_SERVER['HTTP_REFERER'];
$engine      = false;
$query       = null;
$query_array = array();
$query_terms = null;


// Remove protocol from start of string
$referer = explode('//', $referer);
if(isset($referer[1]))
	$referer = $referer[1];
else
	$referer = $referer[0];


// Remove www. is it exists
if(substr($referer, 0, 4) == 'www.')
	$referer = substr($referer, 4);


// Get substrings
$sub7  = substr($referer, 0, 7);
$sub9  = substr($referer, 0, 9);
$sub10 = substr($referer, 0, 10);
$sub11 = substr($referer, 0, 11);
$sub12 = substr($referer, 0, 12);
$sub13 = substr($referer, 0, 13);
$sub14 = substr($referer, 0, 14);
$sub15 = substr($referer, 0, 15);
$sub16 = substr($referer, 0, 16);
$sub17 = substr($referer, 0, 17);
$sub19 = substr($referer, 0, 19);
$sub20 = substr($referer, 0, 20);
$sub23 = substr($referer, 0, 23);

// Search string for engine and set query delimiter
if($sub7 == 'google.')
{
	$engine    = 'google';
	$delimiter = "q";
}
elseif($sub13 == 'search.atomz.')
{
	$engine    = 'atomz';
	$delimiter = "sp-q";
}
elseif($sub11 == 'search.msn.')
{
	$engine    = 'msn';
	$delimiter = "q";
}
elseif($sub13 == 'search.yahoo.')
{
	$engine    = 'yahoo';
	$delimiter = "p";
}
elseif($sub16 == 'msxml.excite.com')
{
	$engine    = 'excite';
	$delimiter = "qkw";
}
elseif($sub16 == 'search.lycos.com')
{
	$engine    = 'lycos';
	$delimiter = "query";
}
elseif($sub13 == 'alltheweb.com')
{
	$engine    = 'alltheweb';
	$delimiter = "q";
}
elseif($sub14 == 'search.aol.com')
{
	$engine    = 'aol';
	$delimiter = "query";
}
elseif($sub15 == 'search.iwon.com')
{
	$engine    = 'iwon';
	$delimiter = "searchfor";
}
elseif($sub7 == 'ask.com')
{
	$engine    = 'ask';
	$delimiter = "q";
}
elseif($sub23 == 'search.cometsystems.com')
{
	$engine    = 'cometsystems';
	$delimiter = "qry";
}
elseif($sub10 == 'hotbot.com')
{
	$engine    = 'hotbot';
	$delimiter = "query";
}
elseif($sub12 == 'overture.com')
{
	$engine    = 'overture';
	$delimiter = "Keywords";
}
elseif($sub15 == 'metacrawler.com')
{
	$engine    = 'metacrawler';
	$delimiter = "qkw";
}
elseif($sub19 == 'search.netscape.com')
{
	$engine    = 'netscape';
	$delimiter = "query";
}
elseif($sub13 == 'looksmart.com')
{
	$engine    = 'looksmart';
	$delimiter = "key";
}
elseif($sub13 == 'go.google.com')
{
	$engine    = 'gogoogle';
	$delimiter = "q";
}
elseif($sub20 == 'dpxml.webcrawler.com')
{
	$engine    = 'webcrawler';
	$delimiter = "qkw";
}
elseif($sub20 == 'search.earthlink.net')
{
	$engine    = 'earthlink';
	$delimiter = "q";
}
elseif($sub20 == 'search.viewpoint.com')
{
	$engine    = 'viewpoint';
	$delimiter = "k";
}
elseif($sub9 == 'mamma.com')
{
	$engine    = 'mamma';
	$delimiter = "query";
}
elseif($sub9 == 'ask.co.uk')
{
	$engine    = 'askcouk';
	$delimiter = "ask";
}
elseif(preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $referer))
{
	$engine    = 'bellsouth';
	$delimiter = "string";
}


// Actually do the work if an engine was found
if($engine)
{
	// Get raw query
	$query = explode($delimiter.'=', $referer);
	$query = explode('&', $query[1]);
	$query = urldecode($query[0]);


	//-------------------------
	// Data has been retrieved
	//-------------------------
	// Additional processing

	// Remove single quotes
	$query = str_replace("'", '', $query);
	// Remove double quotes
	$query = str_replace('"', '', $query);
	// Split into words
	$query_array = preg_split('/[\s,\+\.]+/',$query);
	// Make single string
	$query_terms = implode(' ', $query_array);
	// Format for HTML display
	$query_terms = htmlspecialchars(urldecode($query_terms));

}

 

so now I need to know how to select the items in my db, compare $query_terms with those items in db, match identical words such as "Denver", drop non matching words, and make the matched words available for use on the main page.

 

Thanks for your time, I could really use some help with this one.

 

Michael Smith

Link to comment
https://forums.phpfreaks.com/topic/150198-dynamic-landing-page/
Share on other sites

Let me see if I can explain this better.

 

What I'm trying to do is recognize the keywords used on a search engine, by an end user when they click on our link in the search engine results.

Then I'd like to match those keywords against the city and states names in my database. When matching words are found, say for example "Phoenix, Arizona" I would then like to have those keywords place strategically throughout the "landing page" that the end user is taken to. Any other words besides "Phoenix, Arizona" would just be discarded and not used. If there are no matches found between the db and the search keywords, then htaccess would redirect to a different, static page.

 

This is basically a take on DKI landing pages but with a twist. There is quite a bit more involved in this but where I'm stumbling is on the matching of the words from the referrer and my mysql db. As I said, I need to have the script pick out the matching city and state names between the two and make them available to me in a variable. Two separate variables would be even better. one for city, one for state.

 

I hope that makes a little more sense, any help provided is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/150198-dynamic-landing-page/#findComment-791127
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.