开发者

How can I alter this script to allow voting once per day?

I'm trying to incorporate the script in this tutorial appreciate badge tutorial开发者_Go百科

but I would like to be able to allow the IP to vote once per day. could anyone offer a suggestion on altering the code?

cheers


Check for the existance of the users IP address in the table with a simple query - then if the entries date is within the last 24 hours dont allow ... simple ...


Update the table definition of appreciate_votes and add a column appreciated_on to store the timestamp. Update the where clause of the query on line 77 with DATEDIFF(now(),appreciated_on)>1

This has not been tested.


A quick and simple way would be to add a field that had a datatype of DATE and add a unique index on that field and your IP field. That way the database will only allow entry per IP + Date combination.

Make sure you change the inserts to INSERT IGNORE so you don't get mysql errors upon insertion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜