1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

need PHP code for clickbank hoplink

Discussion in 'PHP' started by jasonwilks, Apr 17, 2016.

  1. #1
    Hello, I am a vendor for clickbank setting up my affiliate links to allow affiliates to use different links to send them to three different pages (products). I am currently using the code below, but it only works for the last "If" statement (product 3) and the "else" statement (product 1), but not for product 2.

    Currently using these three clickbank links:

    AFFILIATE.VENDER.hop.clickbank.net/

    and

    AFFILIATE.VENDER.hop.clickbank.net/?site2=product2

    and

    AFFILIATE.VENDER.hop.clickbank.net/?site3=product3

    code:

    <?php
    $site2 = $_GET['site2'];
    $site3 = $_GET['site3'];

    if($site2 == "product2")
    {
    $address = "www.example.com/product2/";
    header("Location: $address");
    }

    if($site3 == "product3")
    {
    $address = "www.example.com/product3/";
    header("Location: $address");
    }

    else
    {
    $address = "www.example.com/product1/";
    header("Location: $address");
    }

    ?>




    So, product 1 & 3 works, but NOT product 2. Can someone tell me if there is something I can fix here to make this work right?
     
    jasonwilks, Apr 17, 2016 IP
  2. Blizzardofozz

    Blizzardofozz Well-Known Member

    Messages:
    132
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    118
    #2
    Why don't make one variable?

    index.php?site=product1
    index.php?site=product2
    index.php?site=product3

    
    $address = "";
    $site = $_GET['site'];
    
    if ($site === "product2") {
       $address = "www.example.com/product2/";
       header("Location: $address");
    } elseif ($site === "product3") {
       $address = "www.example.com/product3/";
       header("Location: $address");
    } else {
       $address = "www.example.com/product1/";
       header("Location: $address");
    }
    
    
    Code (markup):
    and this case is suitable for switch statement.
     
    Blizzardofozz, Apr 18, 2016 IP
  3. jasonwilks

    jasonwilks Well-Known Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #3
    That worked, thank you!
     
    jasonwilks, Apr 18, 2016 IP