how to get value from one page into another page via URL through session in PHP
I am new in PHP and I am doing some work I have two Page 1) link.php 2) golink.php
link.php
<ul>
<li><a href="golink.php">Home</a></li>
<li><a href="golink.php">About us</a></li>
<li><a href="golink.php">Highlights</a></li>
<li><a href="golink.php">Price</a></li>
<li><a href="golink.php">Location Map</a></li>
<li><a href="golink.php">Payment Plan</a></li>
</ul>
When I click any link, I want to get the name of that link in golink.php page.
Example:- If I click Home link, I need to get Home value in golink.php page.
I dont want to pass id value in href link like<a href="golink.php ? value= home">Home</a>
I want any other method like session.
Please help me. Thanks in advance.
Answer
Solution:
use the $_SERVER['HTTP_REFERER']. It will show the previous url.
Answer
Solution:
Unfortunately the HTTP_REFERER value will not help him... You could mess around by using hidden forms to pass a POST variable, but it's truly not worth it (messy, just not how it should be done).
I'd strongly recommend using a simple elegant (obvious) solution, especially since your new to php and don't want to form too many bad habits early on ;)
Answer
Solution:
Possible with Javascript.
Example with Javascript and a cookie
This uses jquery and makes it easier to read. Still not the best solution. Since the visitor needs JS and Cookies enabled. The Skript creates a cookie called "linkname" and you can read the value in golink.php with $_COOKIE['linkname'] Best solution is really a query.
_COOKIE docs at php.net