I’m making a comment box. but i want so when people click submit comment, then they time get logged into mysql togheter with the other info i logg. heres the code i use:
if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
{
$query = mysql_query("SELECT * FROM comment WHERE username='$username'");
if(mysql_num_rows($query) > 5 ){
echo "Slow down! you can only send 5 comments a day";
}else{
mysql_query ("insert into comment(username,comment)values('$username','$comment')");
header('location: succes_comment.php');
}
}
?>
so if a user clicked that, then the mysql time colonnum got the username, comment and the time he sent the comment.
you need to add the datetime column in your database. lets name it ‘time_posted’ Then when you insert a row you do it like this:
and when you check that a user submits at most, let say 1 comment in a minute, you do this :
so you will get the amount of messages he placed in the last minute, and by that you can prevent him from posting more.