I want to pass a jquery variable from page1.php to page2.php. For this, I am using hidden form input method. In page1.php,
<form method="POST" action="page2.php" id="myform">
<input type="hidden" id="myField" name="myFieldName">
</form>
And the value for this input field is getting from a script:
<script>
activeCount = 2; //some value
$("#myField").val(activeCount);
</script>
Now in page2.php,
I cant get the variable printed in page2.php.
In page2.php, I am using the below code:
<?php
$myfname = $_POST['myFieldName'];
echo $myfname; // I cant get this printed.
?>
Please help. This question is different in the sense, I want to pass the variable from one php file into another, not a js file.