我有一个评论系统,用户可以在其中发布他们对某些事情的看法,但是如果你按“发布!” 按钮多次,多个查询被插入到数据库中,结果是垃圾邮件。
这是我的代码:
if(!empty($_POST["artcomment"])) {
$postComment = $DB->real_escape_string($_POST["artcomment"]);
$poster = $dbuser;
$postDate = date("Y-m-d H:i:s");
$attachId = $id;
$prepareComment = $DB->prepare("INSERT INTO article_comments (attach_id, comment, poster, date) VALUES ('".$attachId."', '".$postComment."', '".$poster."', '".$postDate."')");
$addComment = $prepareComment->execute();
}
现在我想知道是否可以设置 60 秒的时间限制,就好像他们运行一次查询(单独!)你必须等待 60 秒才能再次执行查询。我看过set_time_limit()
但我不完全确定它是如何工作的。