i am having a php file that is saving data into database, i want the file to keep on running even if the browser is closed. this is what i tried: js.php file:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
setInterval(function() {
$.get('http://localhost/cryptopiamodelp/tst.php/', function(data) {
//do something with the data
alert('Load was performed.');
});
}, 5000);
</script>
tst.php file:
<?php
$con = mysqli_connect('localhost','root','','cryptopiamodel') or die(mysql_error());
$sqli = "INSERT INTO test VALUES ('')" or die(mysqli_error());
mysqli_query($con,$sqli) or die(mysqli_error($con));
?>
but this only works when the browser is opened, is this possible in php to execute js.php file when the browser is closed so that the data is saved into database continuously? Thanks in advance.