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 redirecting hoplink

Discussion in 'ClickBank' started by jasonwilks, Sep 28, 2010.

  1. #1
    Hello, I am a vendor and I have several products to sell under one clickbank account, and I need to know what is the PHP code to use to redirect a hoplink to another website.

    I take it I need to use what clickbank calls (passing parameters), as it states on their website:

    ************************************
    Passing Parameters

    Advanced Users: If you’d like to pass additional parameters through your HopLink that will arrive at the HopLink Target URL, you can do so. We will pass up to 64 bytes of QUERY_STRING data through to the HopLink Target URL.

    For example:

    http://alan.veronica.hop.clickbank.net/?ZZ=1&YY=123abc would redirect to http://veronicas-site.com/script.php?hop=alan&ZZ=1&YY=123abc.

    Please note that passing data is entirely optional.
    ************************************

    So I just need some simple PHP that will help me deal with the extra paramaters to send the customers to a different page other than the default.

    Anybody know what the code may be?

    Thanks,
    Jason
     
    jasonwilks, Sep 28, 2010 IP
  2. digitalkev

    digitalkev Peon

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To redirect and keep the parameters you need to first grab the parameters in the default page and then from there make the redirection with the 'header' command. The code would be: (i'm using the parameters from your example, the lines that begin with // are comments.

    <?php
    //First get the users parameters
    $ZZ = $_GET['ZZ'];
    $YY = $_GET['YY'];

    //Then redirect to the other page
    $address = "theothersite.php/?ZZ=$ZZ&YY=$YY";
    header("Location: $address");
    ?>

    Make sure this is the first thing that appears in the page, before any html tag. In fact, you dont need any html tag...
    Make sure the page where this code appears is a .php page.
     
    digitalkev, Sep 29, 2010 IP
  3. jasonwilks

    jasonwilks Well-Known Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #3
    Thanks for replying, but wow I am so confused! Here is exactly what I am trying to do, maybe we can get the exact code I need to make this work...

    In clickbank I have my product go to a php file called "home.php", right now the code is this (just to go to the first product):
    **********************************************
    <?php
    header("Location: http://www.site.com/product1/");
    ?>

    **********************************************

    It's currently just a simple redirect to my homepage.

    Now, I have 2 separate products to sell under this one clickbank account, with two different landing pages.

    So lets see if I got this right:

    **********************************************
    <?php
    //First get the users parameters
    $product2 = $_GET['product2'];

    //Then redirect to the other page
    $address = "http://www.site.com/product2/";
    header("Location: $address");
    ?>

    **********************************************
    (But this does not work!)

    So what I'm trying to do is:

    So then any time I have someone use the affiliate link of:

    http://affiliate.publisher.hop.clickbank.net/?product2

    Would then take them to:
    http://www.site.com/product2/

    And then of course the default (http://affiliate.publisher.hop.clickbank.net/), would only take them to:
    http://www.site.com/product1/

    You see what I mean, I just need the right code to make this work!

    Thanks,
    Jason
     
    jasonwilks, Sep 29, 2010 IP
  4. digitalkev

    digitalkev Peon

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need an if statement, and the variable to use will be something like $product.

    The link that will be given to your customers, if you want them to go to product 2 is:
    http://affiliate.publisher.hop.clickbank.net/?product=2

    <?php
    //First get the users parameter
    $product = $_GET['product'];

    // Now we'll check what's in the variable product. If there's a 2, then you'll go to
    // product 2. Any other value will make the page load as normal.

    if($product == "2")
    {
    $address = "http://www.site.com/product2/";
    header("Location: $address");
    }
    //if you have another product, you could add the following.. you must change the
    //variable in the link the user clicks on from 'product=2' to 'product=3'

    elseif($product == "3")
    {
    $address = "http://www.site.com/product3/";
    header("Location: $address");
    }

    ?>

    I hope this works for you.
     
    Last edited: Sep 29, 2010
    digitalkev, Sep 29, 2010 IP
  5. jasonwilks

    jasonwilks Well-Known Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #5
    Hey thanks it works! Except for one important thing! A default affiliate link with no extra parameters (such as: http://affiliate.publisher.hop.clickbank.net/ ), takes you to a blank page! We need to some how make it so if there is no parameters it takes you to the default homepage (of my first product, this does not need the extra parameters). Is there a way to do that or am i doomed?
     
    jasonwilks, Sep 30, 2010 IP
  6. digitalkev

    digitalkev Peon

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You need an else statement at the end:

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

    So the whole code will look like this:
    <?php
    //First get the users parameter
    $product = $_GET['product'];

    // Now we'll check what's in the variable product. If there's a 2, then you'll go to
    // product 2. Any other value will make the page redirect to product 1.

    if($product == "2")
    {
    $address = "http://www.site.com/product2/";
    header("Location: $address");
    }
    else
    {
    $address = "http://www.site.com/product1/";
    header("Location: $address");
    }

    ?>

    If you have a bunch of products it will be easier to do a "switch" statement instead...

    Try it and let me know if this works this time.
     
    digitalkev, Sep 30, 2010 IP
  7. jasonwilks

    jasonwilks Well-Known Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #7
    Yes everything works now thanks a lot!
     
    jasonwilks, Sep 30, 2010 IP