Error why for the second time antiflood not working?

Help :(
Antiflood triggered only once, and as soon as the time ends, you can write freely whatever you want, I do not know what I did wrong
Here is the code
case 'writes':
if($udata[lvl] <= 4){
echo "<div class="\"block" tmar _center\">To chat you can write with 5 levels.</div><div class="\"block" tmar _center\"><a href="\"chat.php\"">" Back</a></div>";break;}
$msg=substr($msg, 0, 512);
$msg = addslashes($msg);
$msg=preg_replace ("|[\r\n]+|si","",$msg);
$a = mysql_num_rows(mysql_query("SELECT FROM komentarai WHERE komentaras komentaras = '$msg'"));
$b = mysql_fetch_array(mysql_query("SELECT kada FROM komentarai WHERE nick = '$log' ORDER BY kada DESC LIMIT 1"));
$data_kom = strip_tags($b['kada']);
$data = date("y/m/d H:i:s", strtotime("+20 seconds"));
$data_dbr = date("y/m/d H:i:s");
$time = date("H:i");
if($data_dbr >= $data_kom && $msg != "")
mysql_query("INSERT INTO komentarai SET nick = '$log', komentaras = '$msg', kada = '$data', time = '$time'");
header('location: http://'.$_SERVER['HTTP_HOST'].'/chat.php'); // TO RE-SENT
$rand = rand(1000,9999);

elseif($data_dbr < $data_kom) // SYSTEM ANTIFLOOD
$sec = $data_kom-$data_dbr;
$rand = rand(1000,9999);
echo "<div class="\"block" tmar _center\">Protection from Flooding! Wait $sec seconds</div>";
<a href="\"chat.php?r=$rand\"">Continue</a>
"; }
June 27th 19 at 14:53
1 answer
June 27th 19 at 14:55
Of course the code is not obvious, but try to read as is
if($data_dbr >= $data_kom && $msg != "")
If the current date is greater than or equal to the date of the last message and the message is not empty.

elseif($data_dbr < $data_kom)
If the current date less the date of the last review

At the same time, which is recorded as the time of the message current is + 20 seconds. this in itself is obsurd because what is in the database to have an extra field, if you can just compare it to the current+20.

If you agree, simply make a withdrawal of all values of terms on the screen and you will see where error.
Error or when it receives data from the database, or not at all in this piece of code.

In General play with the dates some very strange.

Find more questions by tags MySQLPHP