Forum Moderators: martinibuster

Message Too Old, No Replies

One More Tip/Tool

         

WallyWorld

1:48 am on Aug 18, 2005 (gmt 0)

10+ Year Member



Since everyone seemed to enjoy the last tip I posted :-) (At least it got you thinking about some new ways to work Ads into your content!) I thought I would toss out a tool that can be worked into some pages to get visitors to maybe stay and read a few more ads.

The tip/tool is a small PHP script I ran accross on-line that allows you to paste a visitors search engine search string into your page on the fly. You can work this into the text or even make it the heading if you so choose. Of course, people search for the craziest terms so you have to be careful how you work it in or it might look stupid.

Also, there is a little snippit you can put into the .htaccess file to make PHP scripts execute even on html pages. Since this isn't a script forum, I didn't want to start pasting the scipts all over this post. Anyone who wants can PM me for them.

Think about it a little. If you have a website about Blue Widgets and someone gets to you site from a search for Bluish Pink Widgets don't you think they would investigate your Blue Widgets page more thoroughly if you had the text "Bluish Pink Widgets" worked into the page somewhere obvious?

Rodney

2:41 am on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see any reason why you couldn't post the script here, other helpful scripts have been posted before.

While the referring keyword script could be used with the best intentions, what you describe is also the same tactic used by the scraper sites to make it seem like their page has relevant content.

WallyWorld

4:21 am on Aug 18, 2005 (gmt 0)

10+ Year Member



OK, I'll post the script before my mailbox fills up further.

Put this line in your .htaccess file in the root directory to make php scripts work in htm and html pages

AddType application/x-httpd-php .html .htm .shtml .php

The following script will put the searched terms where ever you put the script. You can use text formating just as if the whole script was just a word. Also, I take the General Message completely out of the quotes because it doesn't always put it in when there isn't a search term. That part seems to be hit or miss. You can also modify or remove the text before the Print $VAR variable. I just use a space and $var between the quotes to just put in the search terms.

<?PHP
if(!isset($HTTP_REFERER)){
print "General message goes here.";
}
else{
$query = split("[?]",$HTTP_REFERER);
$div = split("[&]",$query[1]);
foreach($div as $var){
if(preg_match("/q=/",$var)){
$var = ereg_replace("q=","",$var);
$var = str_replace("+"," ",$var);
print "So, you're looking for info about $var";
}
else{
}
}
}
?>

The great part about PHP scripts is that they are executed before the page is served so the visitor can't view the page source and see the script. They only can see the resulting text or lack thereof.