Linking Using Php

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 22, 2009, 09:20 AM
430710 members and 297842 Topics
Latest Member: Jealseliawn
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: OmniPotens, yawa-ti-de)  |  Linking Using Php
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Linking Using Php  (Read 51 views)
mikkytrio
Linking Using Php
« on: November 01, 2009, 12:54 AM »

please can php variables be transfered from one page to another not in forms? eg

index.php
<?php
$name = "yaro dan baba";
$surname = "dan yaro";
<html>
<body>
<a href="friends.php"><?php echo "$name";?></a>
</body>
</head>

?>

when the $name is clicked it leads to friends.php and on the friends.php page a new variable is declared but with same value as $surname
friends.php
<?php

$re = $surname; //or so am not so sure how this is done please this is where i am stuck


just like the $_POST or $_GET for forms i want to try the one for hyperlinks please

yawa-ti-de (f)
Re: Linking Using Php
« #1 on: November 01, 2009, 02:26 AM »

<a href="friends.php?surname=<?php echo $surname;?>"><?php echo $name;?></a>

Also, u might wanna get rid of the spaces between the words in those variables.  You could either replace the spaces with hyphens or underscores or assign each word to a separate variable, attach them to the hyperlink like so:

<a href="friends.php?surname1=<?php echo $surname1;?>&surname2=<?php echo $surname2;?>">
    <?php echo $name;?>
</a>

then on the friends.php page, you concatenate the variables.  Good luck!
mikkytrio
Re: Linking Using Php
« #2 on: November 01, 2009, 02:33 AM »

thanks blood. let me try it out
yawa-ti-de (f)
Re: Linking Using Php
« #3 on: November 01, 2009, 09:11 AM »

no yawa.

By the way, You will have to use $_GET on the friends.php page, since you are getting the values passed via url.  There's no escaping that.  It doesn't apply to only forms.  Also, personally, I prefer $_REQUEST, which covers both POST and GET, to using either-or.

good luck!
 Website Review - timmy  Qgroup4u.com Test, Learn, Study & Speak The English Language Online  Help  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.