Need help with cloaking/re-direct scipt!

Discussion in 'PHP' started by LiftBigEatBig, Nov 6, 2008.

  1. #1
    Been working on this cloaking/re-directing script for Affiliate marketing purposes. I can't quite get it to work. I want to check the referrer domain that has gotten to my site. If it is a certain domain I want to display a page on my domain, and if it is any other referrer domain I want to re-direct to my affiliate link. Please help!

    This is what mydomain.com/index.php looks like:

    
    <?php
    
    if(stristr($_SERVER[’HTTP_REFERER’],”referrerdomain.com/”)==FALSE)
    
    {
    
    header( 'Location: http://affiliatelink.com' ) ;
    
    }
    
    else
    {
    header( 'Location: http://www.mydomain.com/signup.html' ) ;
    }
    
    ?>
    
    PHP:
    These are the errors I'm getting:

    Warning: Division by zero in /home2/...../public_html/mydomain/index.php on line 3

    Warning: Cannot modify header information - headers already sent by (output started at /home2/...../public_html/mydomain/index.php:3) in /home2/...../public_html/mydomain/index.php on line 13

    Any help is greatly appreciated!!!
     
    LiftBigEatBig, Nov 6, 2008 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Try this.

    <?php
    if(stristr($_SERVER['HTTP_REFERER'],"referrerdomain.com/")==FALSE)
    
    {
    
    header( 'Location: http://affiliatelink.com' ) ;
    
    }
    
    else
    {
    header( 'Location: http://www.mydomain.com/signup.html' ) ;
    }
    
    ?>
    
    PHP:
    Notice your double quote ( " ) became ( ” ) and also the single quote is having the same problem.
     
    ads2help, Nov 6, 2008 IP
  3. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Your first if statement is also wrong.
    As stristr returns a pointer, you have to use three = instead of two.
    Like:
    
    <?php
    if(stristr($_SERVER['HTTP_REFERER'],"referrerdomain.com/") === FALSE)
    
    {
    
    header( 'Location: http://affiliatelink.com' ) ;
    
    }
    
    else
    {
    header( 'Location: http://www.mydomain.com/signup.html' ) ;
    }
    
    ?>
    
    PHP:
     
    elias_sorensen, Nov 6, 2008 IP
  4. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #4
    Or here is the simplest example

    <?php
    if (stristr($_SERVER['HTTP_REFERER'], 'google.com')) {
       echo 'You are from Google';
    } else {
       echo 'You are not from Google';
    }
    ?>
    PHP:
     
    xrvel, Nov 7, 2008 IP