I have a form on page1.php which redirects to page2.php, I want to pass the data from the form to page3.php immediately on load of page2.php. (the user doesn't need to see what's going on in page3, only page2)
What should I use to pass the variables? Currently I'm using
page1.php
<html>
<form action=page2.php method=post>
<!-- form content here incl name attr for input elements -->
</form>
</html>
page2.php
<body>
<?php
$var1 = $_POST['name1']; // int
$var2 = $_POST['name2']; // int
$var3 = $_POST['name3']; // int
$var4 = $_POST['name4']; // str
?>
<!-- some code here -->
<script>
var var1 = <?php echo $var1; ?>;
var var2 = <?php echo $var2; ?>;
var var3 = <?php echo $var3; ?>;
var var4 = "<?php echo $var4; ?>";
$.post('page3.php',{var1: var1, var2: var2, var3: var3, var4: var4});
</script>
</body>
page3.php
<?php
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];
$var3 = $_POST['var3'];
$var4 = $_POST['var4'];
?>
a. This seems like way too much to me, are there any jquery shortcuts? How can I use serialize to help me? b. this isn't working entirely... I think there's some problem with the $.post, maybe I'm not triggering it well? I am not sure.
Help would be appreciated.