Filing cabinet clickado.php
<?php
$time = time();
$usuario = $_POST['usuario'];
$fp = fopen("timerdobotao.txt", "w+");
$escreve = fwrite($fp, $time);
fclose($fp);
?>
Filing cabinet php check.
<?php
$arquivo = fopen ('timerdobotao.txt', 'r');
$rt = "false";
while(!feof($arquivo)){
$linha = fgets($arquivo, 1024);
if($linha !=""){
if($linha < (time() - (1 * 60 * 60))){ // horas * minutos * segundos
$rt = "true";
}
}
}
echo $rt;
?>
In your html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function ClickDoBotao(){
var usuario = "idDoUsuario";
$.post("clickado.php",{usuario:usuario}function(){
})
}
setInterval(function(){
var usuario = "idDoUsuario";
setInterval(function(){
$.get("verificabotao.php",{usuario:usuario},function(rt){
if(rt == "true"){
$("#meuBotao").prop("disabled",false);
}else{
$("#meuBotao").prop("disabled",true);
}
});
}, 5000);
});
</script>
Cire a button and assign an id
<button onclick="ClickDoBotao()" id="meuBotao">
Obs had no way to test the code but the logic is this
You’re talking about two people on different computers, interfering with each other’s button without the need for BD?
– David Alves
Yes, for example button 1 is active, and someone clicked, so others can only click after one hour. Under these conditions the button would be disabled on my server (in the code). So there is no need for a BD, it is possible?
– Erick
No database connection, I don’t think it’s possible.
– David Alves
well you can generate a txt file ai check the time pressing from there
– Marcos Brinner
Okay Marcos, it’s a really great idea, but how exactly would I do it?
– Erick
You can use a real time structure, this way in each access of a new user, creates a session on the server. I recommend the use of Nodejs with Socket io..
– hyp
I added an answer, more or less the logic is this, but I had no way to test here
– Marcos Brinner
I added my answer option with Jquery.
– user60252