₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,957 members, 8,424,328 topics. Date: Thursday, 11 June 2026 at 02:44 AM

Toggle theme

Linking Using Php - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersLinking Using Php (765 Views)

1 Reply (Go Down)

Linking Using Php by mikkytrio(op): 12:54am On Nov 01, 2009
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
Re: Linking Using Php by yawatide(f): 2:26am On Nov 01, 2009
<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!
Re: Linking Using Php by mikkytrio(op): 2:33am On Nov 01, 2009
thanks blood. let me try it out
Re: Linking Using Php by yawatide(f): 9:11am On Nov 01, 2009
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!
Re: Linking Using Php by paulomx: 3:46pm On Dec 08, 2009
$_REQUEST is beter

in real time development u hardly see $_GET cos of input data privacy,
Re: Linking Using Php by DualCore1: 5:22pm On Dec 08, 2009
Yawa I dont see how your solution will work for this guy o. From what I am understanding from his first post, he wants the value of a variable in index.php to be transfered to friend.php.

Well i just work up and i'm still seeing double but here is what I am thinking should work as a solution.

Index.php
<?php
session_start();
$name = "yaro";
$surname = "dan";
$_SESSION['surname'] = $surname;
?>
<html>
<head></head>
<body>
<a href="friends.php"><?php echo "$name";?></a>
</body>
</html>


friend.php
<?php
session_start();
$re = $_SESSION['surname'];
?>
Re: Linking Using Php by yawatide(f): 6:23pm On Dec 08, 2009
Well, there is more than 1 way to skin a cat. Your solution works too. Of course, the argument now, given the original post, becomes which method is more efficient. that, I will leave for the pros to answer cool
1 Reply

Problem: Centering Text Using Php's ImagettftextDoes Anyone Know How To Send Emails As Sms To Mobile Phones Using PHPWriting A Time Based Expiration Script Or Function Using Php And Mysql234

How Can I Make 20 Posts In My Furum To Show At The Same Time On The Screen.How Online Hotel Reservation Work?New Comer