Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-25-2012, 03:25 AM   PM User | #1
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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/
Eggweezer is offline   Reply With Quote
Old 07-25-2012, 03:40 AM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,150
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
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
DrDOS is offline   Reply With Quote
Users who have thanked DrDOS for this post:
Eggweezer (07-25-2012)
Old 07-25-2012, 11:18 AM   PM User | #3
Eggweezer
New Coder

 
Join Date: May 2012
Posts: 97
Thanks: 75
Thanked 0 Times in 0 Posts
Eggweezer is an unknown quantity at this point
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.
Eggweezer is offline   Reply With Quote
Old 07-25-2012, 12:25 PM   PM User | #4
connormcwood
New Coder

 
Join Date: Sep 2011
Location: Blackpool
Posts: 31
Thanks: 6
Thanked 1 Time in 1 Post
connormcwood has a little shameless behaviour in the past
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.
__________________
Google was late to search. Facebook was late to social networking. Apple was late to the MP3 player. It's never too late. Just do it better
My website: http://www.connormcwood.com/forum/
connormcwood is offline   Reply With Quote
Reply

Bookmarks

Tags
hyperlink variable

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:05 AM.


Advertisement
Log in to turn off these ads.