Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2012
    Posts
    145
    Thanks
    114
    Thanked 0 Times in 0 Posts

    Passing variable via hyperlink?

    I am trying to understand "Passing variables via hyperlinks".
    I found a website that explains how to do that, BUT, it does not work for me.

    The site:
    http://mrarrowhead.com/index.php?pag...iables.php#get

    The html code
    Code:
    <a href="http://yourdomain.com/catching-var.php?<span class="bold">name=Shaun</span>
    <span class="bold">&Lname=Morgan</span>">Test Page 1</a>
    The code on the php page receiving and displaying the "name" variables
    Code:
    <h2>catching-var.php</h2> 
    <hr />
    <?php
    
    $name = $_GET['name'];
    $Lname = $_GET['Lname']; 
    echo $name.'<br/><br/>'; 
    echo $Lname.'<br/><br/>'; 
    ?>
    I believe the php code to receive & display the variables appear to be correct, but it seems that the variables are not being passed (or I am doing something wrong).

    I would appreciate if someone would please help me understand. Sincerely, Eggweezer
    My example is at : http://briskeee.org/

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,990
    Thanks
    15
    Thanked 233 Times in 233 Posts
    The code on that example will only work if you copy and paste the link into your browser window. If you want the link to work directly do it this way.
    PHP Code:
    <a href="http://yourdomain.com/catching-var.php?name=Shaun&Lname=Morgan">Test Page 1</a

  • Users who have thanked DrDOS for this post:

    Eggweezer (07-25-2012)

  • #3
    Regular Coder
    Join Date
    May 2012
    Posts
    145
    Thanks
    114
    Thanked 0 Times in 0 Posts
    Thank you very much. That is really cool. I never realized that you could pass a variable that way. That is a useful feature! Thanks again.

  • #4
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    PHP Code:
    $table "SELECT * FROM users";
    $test mysql_query($table); 

    echo 
    "<table><tr><th>Username</th>";
    echo 
    "<th> </th>";
    echo 
    "<th>Created</th>";
    echo 
    "<th>Infastructure</th>";
    echo 
    "<th>Statename</th>";
    echo 
    "<th>Money</th></tr>";
    while (
    $row mysql_fetch_array($test)) { 
     echo 
    '<tr><td><a href="profile.php?user='
        
    $row['username'] . '">'
        
    $row['username'] . '</a></td><td>
        <a href="sendmessage.php?user='
        
    $row['username'] . '"><img src="images/messageicon.png" alt='
        
    $row['username'] . '</img></a></td><td>'
        
        
    $row['dayregistered'] . '</a></td><td>'
        
    $row['infrastructure'] .  '</td><td> '
        
    $row['statename'] .  '</td><td> $'
        
    $row['money'] . '</td></tr>';
        
     }
    echo 
    "</table>"
    I use this code in my script. Hope it helps.
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •