When user click claim button, i want to run javascript function every 5 sec. After i build up this code, and clicked the button but the script doesn't work. I'm not good at javascript at all. All i know is some php and mysql.
When user clicked claim button, the function send() should call payout() function and run this crul() function which is inside payout() function. I don't know where i make mistake as i don't know much javascript.
this is the button function i build up. don't know if it wrong or not.
<button onclick="send()" class="btn-success"><i class="fas fa-exclamation-circle"></i> Claim <i class="fas fa-exclamation-circle"></i></button>
<script>
function send() {
setInterval(function(){ payout(); }, 5000);
}
</script>
This is the function payout()
function payout(){
$sql = $conn->query("UPDATE wallets SET balance = balance - 1 WHERE wallet = '$wallet' " );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://faucethub.io/api/v1/send");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"api_key=$apikey&to=$wallet¤cy=$shortcurrency&amount=$doge ");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
}
The result should be payout() function should send to that $wallet every 5 sec