my code is something like taxi counter but with time when i click on start "time starts going" and when i click on confirm i want the code to collect thae values that have changed in "money" and "time" section and sends it to database i didn't know what's exactly the error in my code
<?php
if (isset($_POST['money'])) {
sleep(4);
$servername='localhost';
$username='root';
$dbname = "khalil";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
$password='';
$money=$_POST['money'];
$hours=$_POST['hours'];
$mins=$_POST['mins'];
$seconds=$_POST['seconds'];
$sql = "INSERT INTO `history` (`prix`,`time1`,`date1`) VALUES (`$money`,`mins`,`wassim`)";
// insert in database
$rs = mysqli_query($conn, $sql);
if($rs)
{
$success= "done";
}
}
?>
$('#confirm').click(function(e) {
e.preventDefault();
clearTimeout(timex);
$.ajax({
method: "post",
url : "collect.php",
data: $('#data').serialize(),
datatype: "text",
success : function (response){
$('#done').html('done'),1000;}
})});
<form id="data" method="post">
</div>
<h4>Post 1 </h4>
<div id="timer">
<span id="hours">00:</span>
<span id="mins">00:</span>
<span id="seconds">00</span>
<br><span id="money">0 $</span>
</div>
<div id="controls">
<button id="start">Start</button>
<button id="stop">Stop</button>
<button id="reset">Reset</button>
<button id="confirm">confirm</button><br>
</form>