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..

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.