pkarthicbz pkarthicbz - 4 months ago 14
PHP Question

how to store a link name in variable on another page

I have assigned a variable to store the link names when i click

echo "<a href ='details.php?id=".$row[0]."<br>'>".$row[0]."<br><br></a>";


so i can get the link name on next page by doing

$id = $_GET['id'];


the above code works fine on next page.

But i want to get the same id value on another page also. when i put the same code as above it doesn't work. so how do i get it. i have three page.

Answer

Get is just sent to the server ONCE. You need to store it. For example you could use sessions in php.

This stores the id.

<?php
session_start()
$_SESSION["id"]=$_GET["id"];
?>

Know you can access the id, until the user resets the browser...

<?php
session_start();
$id=$_SESSION['id'];
?>