Passing variable through link

Discussion in 'PHP' started by GrassR00ts, Mar 13, 2008.

  1. #1
    Hello All

    Quick question. I have a script set up that passes an id number in the URL. The link ends up looking like this

    http://website.com/search.php?id=20

    on the search php page I want the outbound link to pass the id (in this case 20) to the next page. Right now I tried to do this on the search.php page

    <a href='http://affiliatelink.com/83dd7?sub=<? echo $id; ?>'>click here</a>

    I dont have anything else on the page in the way of code to pull the value you. I feel like I might need something else like <? $id=$_GET['id']; ?> on the page somewhere but not sure.

    Any help with this would really be appreciated

    Thanks!
    Alex
     
    GrassR00ts, Mar 13, 2008 IP
  2. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #2
    aaron_nimocks, Mar 13, 2008 IP
  3. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks for the help

    I have a landing page that pulls in info and gives the visitor an id. I can pass that id out of the landing page directly to the affiliate offer and it records it. Now what I want to do is add a page in the middle of this process but still have it pass the same id number, so it would look like this landing page -> jump page -> affiliate offer

    Does that clear it up a little?

    Thanks again
     
    GrassR00ts, Mar 13, 2008 IP
  4. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If on step one you make the value of id = 20 and go from that page to http://yoursite.com/jump_page.php?id=20 the value of id on the jump page is still 20 so if you have a link on jump page and call it just like you did <a href='http://affiliatelink.com/83dd7?sub=<? echo $id; ?>'>click here</a> the html after php has done it's job should read it should read http://affiliatelink.com/83dd7?sub=20

    There's no need to redeclare the variable id again on the jump page
     
    Edynas, Mar 13, 2008 IP
  5. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #5
    for some reason it does not seem to be going to second time through

    so after i click the link on the first page the url on top of the second page looks like this

    http://website.com/search.php?id=23

    then on the search.php page i have link out that looks like this

    <a class='lin' href='http://affiliate.com/3hd7s3?sub=<? echo $id; ?>'>click here</a>

    Did i do somthing wrong maybe with the syntax for <? echo $id; ?>??

    Thanks again for all the input
     
    GrassR00ts, Mar 13, 2008 IP
  6. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #6
    I would post the PHP code for the pages and explain. Kind of hard to see the problem without seeing the code.
     
    aaron_nimocks, Mar 13, 2008 IP
  7. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Sure, here is the jump page code. Now looking at it iam wondering if the javascript at the top doing the redirect is not able to pull the id.

    <HTML>
    
    
    <HEAD>
    <TITLE>Find a deal</TITLE>
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    
    <style type="text/css">
    <!--
    
    .style1 {
    	font-size: 17px;
    	font-family: Arial, Helvetica, sans-serif;
    }
    
    
    .lin a:link {
    	text-decoration: none;
    	color: #000000;
    }
    .lin a:visited {
    	text-decoration: none;
    	color: #000000;
    }
    -->
    </style>
    </HEAD>
    <script type="text/JavaScript">
    
    function changeContent(){
    
    	setTimeout(redirect, 1500);
    }
    
    function redirect(){
    	window.location.href = "http://affiliate.com/132sdf7?sub=<? echo $id; ?>";
    }
    
    window.onload = setTimeout(changeContent, 1500);
    
    </script>
    <body>
    
    <center>
    	<br>
    	<br>
    	<br>
    	<br>
    	<br>
    	<br>
    	<br>
    	<br>
    	<br>
    	
    <div align="center">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
    
              
                    <tr>
                      <td align="center"><p class=style1 align='center'>	
    Please wait, we are searching for the best deal<br><br>
    <img src="/img/loading.gif" width="48" height="48"><br>
    <br>
    If you are not automatically redirected, please <a href="http://affiliate.com/1df3s7?sub=<? echo $id; ?>">click here</a>.
    </p></td></tr>
                    </table>
    </div>	
    
    </center>
    
    
    </body>
    
    </HTML>
    PHP:
     
    GrassR00ts, Mar 13, 2008 IP
  8. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Would it help if i posted the first page of the code?
     
    GrassR00ts, Mar 14, 2008 IP
  9. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Well I can't see your $_GET where is it?

    I assume this is your url: yoursite.com/search.php?id=20
    Now are you using PHP4 or PHP5? if you are using PHP5 then you need to use this PHP opening tag as <?php and not just <?

    Ok, now do some changing into your JavaScript redirect to as:

    function redirect(){window.location.href = "http://affiliate.com/132sdf7?sub=<?php echo $id=$_GET['id']; ?>";}


    Gonzo
     
    Gonzo4u, Mar 14, 2008 IP
  10. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #10
    I took the get out because it seemed that it was passed through the first page, do i need to add that to the second page?
     
    GrassR00ts, Mar 14, 2008 IP
  11. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #11
    hmm... to understand your problem, you need to post all your connecting pages, you can hide and change your data fields if you like, but to check your complete routine it is required.

    Gonzo
     
    Gonzo4u, Mar 14, 2008 IP
  12. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Rip out all that code and just do this:

    
    <html>
    <head>
    <?php 
      echo "<meta http-equiv=\"refresh\" content=\"0;url=http://affiliate.com/1df3s7?sub=" . $_GET['id'] . "\"/>";
    ?>
    One moment while you are automatically redirected.
    </head><body>
    
    PHP:
     
    Christian Little, Mar 14, 2008 IP
  13. webmaster_TSU

    webmaster_TSU Peon

    Messages:
    449
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #13
    You need to do the $_GET on the second page as well, or else $id is just going to be = "" .
     
    webmaster_TSU, Mar 14, 2008 IP
  14. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #14
    Christian Little that worked great! Is there any way to make it pause for 2 or 3 seconds?

    Thanks!
     
    GrassR00ts, Mar 14, 2008 IP
  15. djacobs

    djacobs Well-Known Member

    Messages:
    238
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #15
    Change the content= variable. It's in seconds.
     
    djacobs, Mar 14, 2008 IP
  16. GrassR00ts

    GrassR00ts Active Member

    Messages:
    614
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    58
    #16
    Thank you djacobs and everyone else for all the help
     
    GrassR00ts, Mar 14, 2008 IP
  17. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #17
    np :) the meta refresh tag works wonders with php :)
     
    Christian Little, Mar 14, 2008 IP
  18. perx

    perx Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #18
    nice job/...
     
    perx, Mar 15, 2008 IP