How to implement a send limit?

Actually, I have a form

echo "<form method='post'>";
echo "<input type='text' name='komy' value = '@'/><br> :<br>";
echo "<input type='text' name='otkogo'><br>:<br>";
echo "<input type='text' name='msg'><br><p><input type='submit' value=''></p>

She calls the script, which is also in this file. Actually a question how to implement restriction on sending? Those. so that the sending was once every 5 minutes, for example. Thanks in advance 🙂

Answer 1, authority 100%

    if(!isset($_SESSION['last_post']) || time() - $_SESSION['last_post'] >= 5*60){
        $_SESSION['last_post'] = time();

Cons: we’re still tied to cookies.

Answer 2

Record the time of the last send in the cookie/session and check: if it is 5 minutes less than the present time, then good, otherwise send to …

Answer 3

If you need by IP, then you will have to save a record in the database in a table with the fields “IP” and “date of form submission” from this IP. Well, accordingly, look at this table every time, check it.