Reputation: 49
I have a popup php page that contains this link within the php file (not the browser):
http://mydomain.com/member.php?id=75
how can I get the id value only to define another variables for the users on that page?
I used the $_SERVER['HTTP_REFERER']; to get the link where user came from.
many thanks,
Upvotes: 2
Views: 112
Reputation: 47945
Try this code here:
$query=parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
$REFERER_GET=array();
foreach(explode('&', $query) as $kv) {
list($key,$value)=explode('=', $kv);
$REFERER_GET[$key]=$value;
}
echo($REFERER_GET['id']);
Upvotes: 0
Reputation: 3694
id in your url is URL parameter which can be extracted using the $_GET variable.
just try printing $_GET variable. and choose the value of id as ($_GET["id"].
Upvotes: 0
Reputation: 769
You could just use $getId = explode("=", $_SERVER['HTTP_REFERRER']);
Then set $id = $getId[1]
(Since the number is going to be the second position of the array).
Upvotes: 1