When submitting a form, we write time.php to the database.
$time = date('Ymd H:i:s'); mysqli_query($link, "UPDATE dbName.table SET `lastAction` = '$time' WHERE `dbName`.`id_user` = $idUser");
Further, in a separate check.php script, you need a function that will return true if more than 15 minutes have passed.
function checkingTheTime($idUsers) { mysqly_query($link, SELECT * FROM `users` WHERE `id`=$idUsers && `online` > NOW() - INTERVAL '15' MINUTE) if(mysqli_affected_rows($link) > 0){ return true; } return false; } $enableSending = function checkingTheTime($idUsers); echo $enableSending;
What is this about php. Further on the page you need js, which will do ajax and change the class of the button (for example, hidden / visible).
$(document).ready(function () { //при нажатию на кнопку, #btn $("#btn").click(function () { $('#btn').addClass('hidden'); $.ajax({ url: "time.php" }); $.ajax({ url: "check.php" }) .done(function (Data) { // Делаем обработку данных returnedData if (Data == true) { $('#btn').removeClass('hidden'); } }); }); });
As for JS, I could be mistaken, but in general, I think the idea is clear.