Reputation: 1
I want to pass a uid to the next page through a query string. How do I pass it and how do I get it on the next page?
Upvotes: 0
Views: 10542
Reputation: 1
//if your data is not danger and Sensitive information send like this
$uid="your variable";
header("location:page.php?uid=$uid")
// get like this in another page (page.php)
$uid=$_GET['uid'];
//if your data is Sensitive information like pass use it
$_SESSION['uid']="your variable";
header("location:page.php?uid=$_SESSION['uid']")
// get like this in another page (page.php)
$uid=$_SESSION['uid'];
Upvotes: 0
Reputation: 61
You can also pass the value from one page to another page using SESSION.
session_start();
$_SESSION['variable name']=$var;
$var is the variable where you store the value that you want to pass to next page and variable name is name of session variable .
In the Next page where you want to fetch.
session_start();
$a=$_SESSION['variable name'];
$a in which you get the value that you store on the previous page.
Upvotes: 1
Reputation: 7780
There are several ways to do that:
For links: pass "uid" as GET parameter in all links: <a href='something.php?uid=$uid ... '
For forms: pass "uid" as POST parameter, this can be done with <input type='hidden' name='uid' value='$uid'>
Also, you may use cookies, see the following article for details: http://php.net/manual/en/function.setcookie.php
Upvotes: 0
Reputation: 382666
i want to pass a uid to next page through querystring.how i pass it and how i get it on next page?
You can create a link like this:
<a href="page.php?var=value">Go</a>
The variable-value pair after ?
will create the query string. Later you can get the query string with $_GET
array like $_GET['var']
for example.
Upvotes: 2