1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to show searched keyword on page?

Discussion in 'Cloaking and Content Generators' started by Amnesic, Oct 2, 2008.

  1. Amnesic

    Amnesic Newbie

    Joined:
    Nov 17, 2007
    Messages:
    24
    Likes Received:
    0
    How can you do something like:

    You came here searching for XXXXX
     
  2. groove

    groove Newbie

    Joined:
    Sep 19, 2008
    Messages:
    10
    Likes Received:
    1
    There is a plugin for this for wordpress. If you like, I can try to find it again...
     
  3. Chris Devon

    Chris Devon Jr. VIP Jr. VIP Premium Member

    Joined:
    Jul 2, 2008
    Messages:
    507
    Likes Received:
    192
    It's not so hard using php. Just look at the refferer, preg match the query, and echo the keywords
     
  4. aaappp3

    aaappp3 Newbie

    Joined:
    Dec 14, 2007
    Messages:
    34
    Likes Received:
    11
    Here's a preg-free version for those who hate preg (because it's crap and fails on some php installations):

    PHP:
    $keyword='';
    $ref=$_SERVER['HTTP_REFERER'];
    if (
    strpos($ref,'.google.')!==FALSE) { $keyword=$_GET['q']; }
    else if (
    strpos($ref,'.yahoo.')!==FALSE) { $keyword=$_GET['p']; }
    else if (
    strpos($ref,'.live.')!==FALSE) { $keyword=$_GET['q']; }
    if (
    $keyword) { echo "You came here searching for $keyword"; }
    It should be fairly obvious to anyone with basic php how to add other search engines.
     
  5. Chris Devon

    Chris Devon Jr. VIP Jr. VIP Premium Member

    Joined:
    Jul 2, 2008
    Messages:
    507
    Likes Received:
    192
    Sorry to ask, it may be a dumb question; are you sure this will work? I don't have time now to test it. The strpos part is confusing me. Doesn't strpos return a number
     
  6. aaappp3

    aaappp3 Newbie

    Joined:
    Dec 14, 2007
    Messages:
    34
    Likes Received:
    11
    Yes, strpos returns a number, but it'll also return FALSE if no match was found, all I'm doing is testing the referrer to see if it contains google or yahoo or whatever, if it does it returns a number, else it returns FALSE.
     
  7. forgot

    forgot Jr. VIP Jr. VIP Premium Member

    Joined:
    May 3, 2008
    Messages:
    936
    Likes Received:
    706
    Location:
    BlackhatWorld
    What do u actually asking, i cant understand :(