Raising a three years old question. How to get a user id from one php file and retrieve it in another php file
From my own experience I tried to get an id from one file to execute it in another to retrieve some data from another website. Whenever the page loads I could see the value in url on my browser but the value is returning empty when I tried to use it. Kindly check below what I have tried and suggest if there is a way I could do it with javascript or jquery or just do it with only PHP.
a.php
<?php
$aa = b.php;
$bar = 1234;
echo “<a href=$aa?$bar target=new window>”Click here”</a>”;
?>
b.php
<?php
$foo = $_GET[$bar];
// this one returns empty. But bar is seen on the url as ?bar
echo $foo;
?>
How u echo the anchor tag doesn't seems good to me, maybe more like:
echo '<a href="'.$aa.'?bar='.$bar.'" target="new window">Click here</a>';
You can access the value like:
$_GET['bar']
And you have to echo $foo
and not $bar
.