Can anyone please help with how to pass a variable to another php page?

Discussion in 'PHP' started by mike33pt, Sep 1, 2008.

  1. #1
    I have a link on my landing page that links to clickbank.

    All of my landing pages have
    <?php $seedvar=$_GET['id'];?>
    Code (markup):
    at the top of the page.

    "id" is a 4 digit number

    This is my link:
    http://myid.vendorid.hop.clickbank.net/?tid=<?php echo $seedvar;?>
    Code (markup):
    So I click the link and the "tid" value is passed all the way to clickbank.

    This works well.

    But I do not want my page to link directly to clickbank. I want to go through a php redirect: links/index.php

    This redirect: links/index.php contains

    <?php header("Location: http://myid.vendorid.hop.clickbank.net?tid=<?php echo $seedvar;?>");?>
    Code (markup):
    So when I click on links/index.php from my referring page I would have thought that the "tid" value is just passed along but it is not.

    I'm not too hot on php so can anyone see where I have gone wrong and how I should do it?

    Thanks
     
    mike33pt, Sep 1, 2008 IP
  2. smbasha

    smbasha Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can not write php tag with in php tag

    Just use like this,

    <?php header("Location: your site here ?tid= $seedvar ");?>
     
    smbasha, Sep 1, 2008 IP
  3. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank for your reply, I tried what you suggested.

    On my php landing page I have a coded link

    <a href="http://domain/index.php?tid=<?php echo $seedvar;?>">Test</a>
    
    Code (markup):
    That generates this link in the browser:

    <a href="http://domain/index.php?tid=test555">Test</a>
    Code (markup):
    Contents of: http://domain/link/index.php are:

    <?php 
    header("Location: http://myid.vendorid.hop.clickbank.net/?tid=$seedvar");
    ?>
    Code (markup):
    And it still does not pass the data over.

    I feel something is not quite right, I just can't see it.

    Could you advise again please?

    Thank you
     
    mike33pt, Sep 2, 2008 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    did you try getting the value?
    i mean $_GET[]??
     
    bartolay13, Sep 2, 2008 IP
  5. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    My landing page link:

    <a href="http://domain/link/index.php?tid=$seedvar">Test</a>
    Code (markup):
    Which displays data in footer as I have
    <?php echo $seedvar;?>
    
    Code (markup):
    in the footer.

    I just tried this in my http://domain/link/index.php redirect

    <?php 
    $seedvar=$_GET['tid'];
    header("Location: http://myid.vendor.hop.clickbank.net/?tid=$seedvar");
    ?>
    Code (markup):
    Still not passing the data.
     
    mike33pt, Sep 2, 2008 IP
  6. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I just tried it this way too:

    <?php 
    $tid=$_GET['seedvar'];
    header("Location: http://myid.vendor.hop.clickbank.net/?tid=$seedvar");
    ?>
    Code (markup):
    Still no data
     
    mike33pt, Sep 2, 2008 IP
  7. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's cool I got it fixed.

    I put this on the landing page

    <a href="http://domain/links/index.php?tid=<?php echo $seedvar;?>">Test</a>
    
    Code (markup):
    And this in the redirect:

    header("Location: http://myid.vendor.hop.clickbank.net?tid=".$_GET['tid']);
    exit(); 
    Code (markup):
    And it worked :)

    Thank you for all your help, much appreciated.

    Regards

    Mike
     
    mike33pt, Sep 2, 2008 IP