Tuesday, 10 September 2013

Pass url variable on to next page?

Pass url variable on to next page?

I need some help on passing a url php variable onto the next page. I've
tried searching throughout the site for help and I've spent a lot of time
trying to figure this out with no luck. Basically I need to be able to
change the paypal link button id on page 2 with the url variable from page
1.
The variable is initially passed along with the URL:
http://www.site.com?p=paypalbuttonid I would like to pass that "p"
variable on to the next page.
Page 1 code (above html):
<?php
session_start();
$_SESSION['paypal'] = $_GET['p'];
?>
Page 2 code (above html):
<?php
session_start();
$p = $_SESSION['paypal'];
?>
I'm calling the variable in a link on page 2 (below html):
<a
href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=<?php
echo $p ;?>" target="_blank" class="btn">
I'm not sure what I'm dong wrong but I'm a complete newbie to PHP so
please help! The variable shows up blank in the URL on page 2. Thank you!
- Chad

No comments:

Post a Comment