views:

15

answers:

1

This is tricky..

I have two sites. Site A and site B. On another site (any site) I post an affiliate link which takes you to site A where I have a script that redirects to site B (so the first link goes to site B after going through site A)

On site A, I have a variable which I'm trying to pass to site B but without putting it in the browser URL, e.g. http://www.siteB.com/?var=blabla

I was advised to try and use js to post the variables to site B. I tried putting this code in site A..

<body onLoad="submit_form();">
<form name="myform" action="http://www.siteb.com" method="POST">
  <input type="hidden" name="var" value="blabla"> 
</form>

<script language="javascript">
  <!--
  function submit_form() 
  {
    document.myform.submit()
  }
  -->
</script>

and on site B I tried using GET to get teh variable but nothing shows up

$var = $_GET['var'];
echo $var;

Must I somehow put the js var in header() ? I'm lost..

+2  A: 

It's because your form is POST-ing the data, but you're trying to access the data from the $_GET array.

Try this:

$var = $_POST['var'];
echo $var;

$_POST contains data sent via POST, $_GET contains data sent via GET.

Michael Robinson
Wow.. Thanks! lol
Cyber Junkie
:) glad I was able to help
Michael Robinson