How to make time-out for clicking the button to send the form using the POST method There is a simple form:

<form action="" method="post"> <input type="text" value="Введите данные"> <input type="submit" value="Отправить"> </form> 

How to take a break between form processing, i.e. you can press only 1 time in 15 minutes

    1 answer 1

    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.