Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display variables passed through href

Status
Not open for further replies.

kathyc20

Programmer
Mar 7, 2001
96
CA
Hello, I have a php script that I'm writing and I am stuck on a few things:

I have the following link below that I need to carry 2 variables over with.

The first one is the product id, and the
second one is the value of a hidden field which contains the last web page the user was on (document.referrer).


Wben they click on this link they are taken to a php page where I need to
display the contents of these variables.

My code isn't working.

Any help would be appreciated.


<html>
<head>
<title></title
</head>

<body>
<br>

<?
print "$prod";
print "$sReferringSite";
>

</body>
</html>
 
Replace the second ? with an ampersand & (you only use one ? for a GET request). If you need it to be XHTML, then use &amp; instead of just &.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
I fixed up the code that Baby Jeffy indicated, but I am still getting no value for variable ReferringSite.
On my first web page on load it displays where I came from.

When I carry the variable forward, to the next web page (web page 2), the value of ReferringSite is ''.

Web Page 1:
<script language="JavaScript">
function setReferrer()
{document.Form1.ReferringSite.value = document.referrer;}
</script>

<body onLoad="setReferrer();">
<form name="Form1">
<input type="text" name="ReferringSite" size="60">
</form>
<A href="</form>

Web Page 2:
<?php
$sTemp = $HTTP_GET_VARS['ReferringSite'];
print "- $sTemp<br>";
?>
 
Ah, it could be an escape issue:
Code:
{document.Form1.ReferringSite.value = [b]escape([/b]document.referrer[b])[/b];}
I don't think you need to unescape it server-side in php.

Oh, try changing your second page to:
Code:
<?php
$sTemp = '';
if (isset($_GET['ReferringSite'])) $sTemp = $_GET['ReferringSite'];
print "- $sTemp<br>";
?>

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
I changed $_GET to $_POST and it still does not work.
 
I suggest maybe it's time for you to make a trip to Mr PHP Manual - and have a look into some of the examples that are posted as well. Learn about the differences between $_POST and $_GET. That's what is holding you up on this.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top