Transferring variables $_get to another page
I need to send /files/pvtexp.php?mid=162664&iid=410046&idat=2008/09&sec=2 over to page set.html so I can retrieve the info. I'm trying to get this to work a开发者_开发技巧m i missing something?
Page 1:
<?php
$uid = "1500"
$sndlnk = "/files/pvtexp.php?mid=162664&iid=410046&idat=2008/09&sec=2";
?>
<a href="set.html?lnk=$sndlnk&user=$uid"> Send to set.html </a>
Page 2 (set.html):
<?php
$lnk = $_GET['lnk'];
$user = $_GET['uid'];
echo $lnk ."\n";
echo $user ."\n";
?>
You need to urlencode()
$sndlink
.
Also, your page is set.html
. Have you set up html
files to be parsed with PHP?
You could also try this...
<?php
$params = http_build_query(array(
'lnk' => '/files/pvtexp.php?mid=162664&iid=410046&idat=2008/09&sec=2'
'user' => '1500'
), '', '&');
?>
<a href="set.html?<?php echo $params; ?>"> Send to set.html </a>
For starters you are missing a semicolon.
Should be
$uid = "1500";
then include the link in your php using an echo statement like so
echo ('<a href="set.php?lnk='.urlencode($sndlnk).'&user='.urlencode($uid).'">Send to set.html </a>');
You need to do
<a href="set.html?lnk=<?php echo urlencode($sndlnk); ?>&user=<?php echo $uid; ?>"> Send to set.html </a>
You need to encode the variable $sndlnk
before sending through the url:
<?php
$uid = "1500"
$sndlnk = urlencode("/files/pvtexp.php?mid=162664&iid=410046&idat=2008/09&sec=2");
?>
<a href="set.html?lnk=$sndlnk&user=$uid"> Send to set.html </a>
At the second page just decode the string:
<?php
$lnk = urldecode($_GET['lnk']);
$user = $_GET['uid'];
echo $lnk ."\n";
echo $user ."\n";
?>
Ok?
In your Page 1example, you're setting query parameters of lnk
and user
<a href="set.html?lnk=$sndlnk&user=$uid"> Send to set.html </a>
^^^ ^^^^
but in your Page 2 PHP, you're retrieving lnk
and uid
instead.
$lnk = $_GET['lnk'];
^^^
$user = $_GET['uid'];
^^^
Since there's no 'uid' in your Page 1 link, $user will come out blank. Change the uid
to user
on page 1 and things should work a bit better
精彩评论