I am completely new to JS and PHP programming. Please help me with the following code..
<?php
echo'
<button id="checkin" onclick="myFunction()">CheckIn</button>
<script>
function myFunction() {
document.getElementById("checkin").disabled = true;
var CheckinoutStatus=true;
$(function(){
$.ajax({
type: "POST",
url: "functions.php",
data: "&CheckinoutStatus="+CheckinoutStatus,
success: function(data)
{
alert("Checked In");
}
});
});
}
</script>
';
if(isset($_POST['CheckinoutStatus']))
{
$CheckinoutStatus=isset($_POST['CheckinoutStatus']);
$update = $db->query("UPDATE Details SET CheckinoutStatus='$CheckinoutStatus' where date='$date' ");
}
?>
Clicking the checkin
button should disable the button, send a CheckinoutStatus variable value of true to the database using an AJAX call, and then show a "Checked In" alert after the database has been updated.
I am defining and setting the variable CheckinoutStatus
to true in js, and
using AJAX, am trying to get that value in PHP and update that data in an existing table. I have not been able to pass the value from js to php.