Need Some Help

Discussion in 'PHP' started by Ferrarislave, Dec 29, 2006.

  1. #1
    I got 1 landing page for some cpa stuff. I would like to have 1 Iframe to be shown for everything except 1 user referer string. How can I do this? This is the following code I have now, but it's not working correctly. Im using regex match (preg_match) with the $SERVER_HTTP_REFERER varible to get the user search string.

    Code:

    So, basically I have two iframes on the same landing page. I want one to only show when the user is refered using the strings miami tshirts. But I want all other referer strings to be shown the 2nd landing page.
     
    Ferrarislave, Dec 29, 2006 IP
  2. RobPinnacle

    RobPinnacle Active Member

    Messages:
    423
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I don't understand...

    Do you want 1 out of every 2 people. Or do you want it from ref=miamitshirts.com?
     
    RobPinnacle, Dec 30, 2006 IP
  3. Ferrarislave

    Ferrarislave Peon

    Messages:
    1,129
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry, I will try to make it more clear. I want the first iframe to only display for people that found the page by typing Miami Tshirts in an SE. And the second to display for every other request.
     
    Ferrarislave, Dec 30, 2006 IP
  4. B.V.E.

    B.V.E. Peon

    Messages:
    106
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The following should work :) :

    <?php
    
    $keywordfilter = "bmiami shirts";
    $iframehtm     = "";
    
    if(PageIsReferedBy($keywordfilter)){
    	$iframehtm = "Your iframe stuff here for the Bmiami Shirts referers";
    }else{
    	$iframehtm = "Your iframe stuff here for all other keywords and referers";
    }
    
    echo $iframehtm;
    
    function PageIsReferedBy($keywords){
    	/* B.V.E. - 2006 - www.bv-evers.com */
    
    	//Referer must be set to be able to continue
    	if(!isset($_SERVER['HTTP_REFERER'])) return false;
    	
    	//Setup different possible KW variations
    	$variation1 = urlencode($keywords);
    	$variation2 = str_replace(" ","%20",$keywords);
    	$variation3 = $keywords;
    	
    	if(strpos($_SERVER['HTTP_REFERER'],$variation1) !== false) return true;
    	if(strpos($_SERVER['HTTP_REFERER'],$variation2) !== false) return true;
    	if(strpos($_SERVER['HTTP_REFERER'],$variation3) !== false) return true;
    	
    	return false;
    }
    ?>
    PHP:
     
    B.V.E., Dec 31, 2006 IP
  5. Ferrarislave

    Ferrarislave Peon

    Messages:
    1,129
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Mmmm, it doesn't seem to be working. It doesn't seem to just abide to Miami Tshirts. If anything contains tshirts it doesn't show the first iframe.
     
    Ferrarislave, Dec 31, 2006 IP
  6. B.V.E.

    B.V.E. Peon

    Messages:
    106
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The PageIsReferedBy function does work, so I guess I misunderstood when and what you exactly want to display... I'm still not 100% sure what you're exactly trying to achieve but you should be able to achieve it by using the provided function in combination with an IF/SWITCH statement...
     
    B.V.E., Jan 1, 2007 IP
  7. Ferrarislave

    Ferrarislave Peon

    Messages:
    1,129
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I actually think it works. I had to clear my cache. It looks to be working. Thanks B.V.E
     
    Ferrarislave, Jan 1, 2007 IP