I'm trying to submit a form to a PHP page, but the data is not accessible from this page, This is my code:
Html code:
<form method="post" id="formid" action="test.php">
<input type="hidden" name="going" id="going" value="" />
</form>
Javascript:
$("#ongoing").change(function() {
var ongoing = $(this).attr('checked');
var input = document.getElementById('going');
var form = document.getElementById('formid');
if (ongoing)
input.value = "1";
else
input.value = "0";
form.submit();
});
test.php
if(isset($_POST['going']))
echo $_POST['going'];
What am I doing wrong?