简体   繁体   English

每x小时PHP注释

[英]PHP Comments every x hours

I am a beginner at PHP, but I am wanting it that a user is able to post a comment 10 times, in the period of 24 hours. 我是PHP的初学者,但我希望用户能够在24小时内发表10次评论。 If they reach 10 comments before this 24 hours is up, they will get a message saying something like "You can not post any more comments", and after the 24 hours, they are able to post again. 如果他们在这24小时内收到10条评论,他们会收到一条消息,提示“您不能再发表评论”,并且在24小时之后,他们可以再次发布。

Any ideas on how I can do this? 关于如何执行此操作的任何想法?

Thanks. 谢谢。

Store the username and timestamp with each comment in your database. 将用户名和时间戳记与每个注释一起存储在数据库中。

When someone tries to comment, make an SQL query to return the comments where that user made the comment and the time was in the last 24 hours. 当有人尝试发表评论时,请执行SQL查询以返回评论,该评论是该用户发表评论的地方,时间是过去24小时内。

If there are 10 results, show the user an error message. 如果有10个结果,请向用户显示错误消息。

Otherwise process as normal. 否则按正常方式处理。

If you have registered users you can store comments and date in database in count them each time you add new comment. 如果您已经注册了用户,则可以在每次添加新评论时将评论和日期存储在数据库中,以对它们进行计数。 If you haven't registered users you can store it in cookies. 如果您尚未注册用户,则可以将其存储在cookie中。 Read about cookies . 了解有关cookie的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM