Please help, how do I add this php code into my pages

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

  1. #1
    Hi all, can anyone here please explain how I would make this work? Not heavily into php but I'm getting hooked.

    I have a set of web pages that are pulling in by "php includes" areas of the page. To make up my page, pretty simple.

    I have a file called header.php which has all the header detail, meta tags, title tags and down to body tag.

    This works fine as I just put an
    <?php include("includes/header.php");?>
    Code (markup):
    in all my pages that call the header.

    Now at the very top of every one of my web pages I have to have:

    
    <?php $seedvar=$_GET['id'];?>
    
    Code (markup):
    Now I tried just putting at the top of my header.php page like this:

    
    <?php $seedvar=$_GET['id'];?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="robots" content="index, follow">
    
    Code (markup):
    But of course it did not work.

    I then tried:

    
     <?php echo <?php $seedvar=$_GET['id'];?>;?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="robots" content="index, follow">
    
    Code (markup):
    That did'nt work either.

    Neither did adding "<?php $seedvar=$_GET['id'];?>" quotes around it.

    So I would really appreciate it if someone could explain this for me.

    Thank you

    Regards

    Mike
     
    mike33pt, Sep 1, 2008 IP
  2. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #2
    What are you doing with $seedvar?

    does the page display a parse error when you run it?

    to me, it just appears that you're getting id, and saving the data in a variable... it doesn't appear that you're using the data to any extent.
     
    Grit., Sep 1, 2008 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Like Grit has said, you will need to say what it is $seedvar is for, what you expect it to do etc
     
    JAY6390, Sep 1, 2008 IP
  4. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for your quick reply.

    I'm using
    <?php $seedvar=$_GET['id'];?>
    Code (markup):
    to carry data 'id' to other pages on my site and ultimately to another web site for log analysis.

    I just need
    <?php $seedvar=$_GET['id'];?>
    Code (markup):
    at the top of all my pages. And as my headers come from php includes I guess I gotta shove it in there somehow.

    If it does not have to go into header.php how else do I get it in the top of my pages.

    Thanks

    Just to add that the refering page to my site will carry this data 'id' that I need to pass along.
     
    mike33pt, Sep 1, 2008 IP
  5. lanmonkey

    lanmonkey Active Member

    Messages:
    549
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Explain this bit in more detail and we might be able to help you

    in php variables do not remain in memory when you go from one page to another. for this to happen you need to use somthing like sessions, cookies or a database... maybe that helps?
     
    lanmonkey, Sep 1, 2008 IP
  6. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's ok I got it figured.

    It's so easy when you walk away and forget all about it. The answer just popped into my head.

    Thanks anyway
     
    mike33pt, Sep 1, 2008 IP
  7. richie.w

    richie.w Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hi mike,

    Can you share how you got it figured out? I am stuck with the same situation..
     
    richie.w, Sep 23, 2008 IP
  8. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #8
    Post your situation here, richie?
     
    ads2help, Sep 23, 2008 IP
  9. richie.w

    richie.w Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ads2help,

    Thanks for your reply.
    Basically, it is for tracking purpose..

    1) www.example.com/index.php?id=10

    2) I would like to capture the id=10 (as above) into a php page.
    Hence, I include the code below into the php page before the <html> tag

    <?php $seedvar=$_GET['id'];?>

    However, whenever I save the php page and reopen it, the code is not there anymore.

    Did I miss out any steps?
     
    richie.w, Sep 23, 2008 IP
  10. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #10
    actually i am not very sure what you mean by that. but just to let u know :

    by having this : $seedvar=$_GET['id'];

    You are only assigning a value($_GET['id']) to $seedvar, not printing out the $_GET['id'] value
     
    ads2help, Sep 23, 2008 IP
  11. richie.w

    richie.w Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ads2help,

    yes, you are right. the intention is the print the value to a Clickbank affiliate link

    http://myid.vendorid.hop.clickbank.net/?tid=<?php echo $seedvar;?>

    Hence, the flow is to pass the id=10 from www.example.com/index.php?id=10 and store it in $seedvar.

    However, I am not able to save the code of

    <?php $seedvar=$_GET['id'];?> to the index.php page before the <html> code.

    After I save the code into index.php and reopen it, the code is not there.

    How can I work this out? Please advice.
     
    richie.w, Sep 23, 2008 IP
  12. mike33pt

    mike33pt Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi I'm responding to your email.

    You will not see the code:
    <?php
    # Grab the source 'id'
    $seedvar=$_GET['id'];
    ?>
    Code (markup):
    in your page. The server executes it and strips it out. But it will still do its job.

    To check this just echo the $seedvar on your page and you will see if it is carried over.
    Regards

    Mike
     
    mike33pt, Sep 23, 2008 IP
  13. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #13
    u mean when u open the file using your php/text editor the <?php $seedvar=$_GET['id'];?> is not there?
    if it is, it is kinda weird =(
    or you mean the html source after loading index.php?
     
    ads2help, Sep 23, 2008 IP
  14. hello340

    hello340 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Hi,
    I am new to php code and have a couple of questions to ask. I have a landing page with the following code on top.

    <?php

    $seedvar=$_GET['id'];

    ?>

    Then a link on the landing page -

    http://www.mysite.com/link -----> this links to my index.php which in turn links to my clickbank product page. The code on the index.php looks like this

    <?php
    $seedvar=$_GET['id'];
    $link = "http://myid.productid.clickbank.net/?tid=".$seedvar;
    header("Location: $link");
    ?>

    I just wanted to know how to test if this code is right and whether the tid value will be picked up by clickbank? Correct me if I am wrong, from what I understand the sequence is as follows

    1. link to my landing page ----> http://www.mysite.com/site.php?tid=50
    2. someone clicks on link (tid "50" is stored) -----> http://www.mysite.com/link
    3. tid "50" stored in index.php
    4. tid "50" sent to clickbank when order is made


    Thanks,
    Jack
     
    hello340, Oct 18, 2008 IP
  15. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #15
    all that code does is redirect you to "http://myid.productid.clickbank.net/?tid=50" or whatever you put as id. What exactly do you want to do? remember the 50 on pages that do not have the 50?

    You would need to use cookies or sessions for that, like so:

    <?php
    session_start();
    $seedvar=$_GET['id']; //if the id may only be a number, you might want to cast it to be an integer or use intval() on it
    $_SESSION['seedvar'] = $seedvar;
    $link = "http://myid.productid.clickbank.net/?tid=".$seedvar;
    header("Location: $link");
    ?>

    as long as you initiate the session on your pages, $_SESSION['seedvar'] will be available on all pages
     
    Kyosys, Oct 19, 2008 IP
  16. hello340

    hello340 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    The landing page is a website for a recommendation for a clickbank product. There are around ~5-6 links on the landing page. I did not want to place a direct link because I wanted to cloak it by first redirecting to the index.php. My goal is just to store the tid link from the a google adwords ad into my site then pass it onto the clickbank landing page, nothing else. Maybe there is a better way to write the code to do this....do you have any suggestions?

    Thanks, Kyosys
     
    hello340, Oct 19, 2008 IP