$time = time(); setCookie('time', $time, time() + 3600); 

How to further prescribe the condition, if, for example, in 3 seconds the page is updated 2 times, then knocked out "Too fast?"

  • each time the scripts are accessed - we write the value in the session, a la lastAction , if currentTime - lastAction <= minTime , then too often. PS: 3 seconds is a lot - Zowie

3 answers 3

You need to build applications so that they are not afraid of frequent reboots. Read about caching. The only thing that should bother you is to reload the page with the form submitted.

  • @ksladkov, did not help .. - ModaL

That's what comes to mind immediately.

With each new update of the page, increment a certain session variable, and, accordingly, write to the array, the time created in the session, when the first increment and the last one were produced. When session variable = 3, then we look at the time when the first increment was produced, that is, the page update counter variable became equal to one. We subtract from the current time what we got. If the result is more than 2 seconds, make a message ...

     if($_COOKIE['time'] <= time()+3){ echo "Слишком быстро!"; } 

    Note that one page may load 3 seconds. Notify, please, about the result.

    • $time = time(); setCookie('time', $time, time() + 3600); if($_COOKIE['time'] <= time() + 3){ echo "Слишком быстро!"; } if($_COOKIE['time'] <= time() + 3){ echo "Слишком быстро!"; } Always displays "Too fast!". 3 changed to +10 and still ... - ModaL
    • and if time () + 3 to enclose in brackets? - atnartur
    • @atnartur, before giving advice, you would first learn php yourself, okay? - johniek_comp
    • @atnartur, did not help: ( - ModaL
    • @johniek_comp, but what's the error then? - ModaL 2:53 pm