Question:
How to pass php variables from one page to another page?
?
2012-02-25 00:05:21 UTC
For example, on this profile

http://localhost/post/users/profile.php?id=1

I can get the current profile id by $_GET['id']; .

But on the same page, I have included a page

How can I get the current URL id on this (wall.php) page ?
Three answers:
anonymous
2012-02-25 02:23:06 UTC
for using a variable on multiple pages you can also use sessions.



like this:
$_SESSION[‘variablename’] = value;?>



in your case it will be


$_SESSION[‘id’] = value;?>



this way the variable can be used as long as the session is active.
Christopher Elison
2012-02-25 00:31:15 UTC
If you're including wall.php in your main script then you should be able to access $_GET/$_POST as you normally would with the main script its being called from.
Beth
2016-02-26 03:34:56 UTC
send as POST and not GET do you have a form on your page? if so change the form action to post if you're not using forms, then look into sessions


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...