How to allow users to make limited action peer day php

Hello, I want to make a pointing system for users I have a points row on my user’s table that will increase every time a user rate a product lets say or review a product what I wnt is to check if the user already rated 5 products today stop giving the user points and the same for the review and the logic of doing something like is what am missing I can’t seem to think of a way to do this so please help me a little do I use cookie and what is the best way to use them or do i use some other way cuz the user could simple delete a cookie and start over and could be spamy and i don’t want that.
And thanks for the help

You can use a combination of cookies and IPs.

you mean that I should store the user IP address on my database?

Are your users registered to your site?

Ye there are register and there info store in the db

If users are registered, better store the timestamp at which they reviewed the products.

Then, in order to check if they’ve reviewed 5 products in a day, count all records of which timestamp is contained between current and next day:

$current_day = mktime(0,0,0,date('j'),date('n'),date('Y'));

$next_day = mktime(0,0,0,date('j'),date('n')+1,date('Y'));

$sql_query = "

SELECT COUNT(*) 
FROM table 
WHERE `reviewed_at` >= '$current_day'
AND `reviewed_at` < '$next_day';

";

well i changed my mind made a new system now the points will only be giving to users when the mod or admins approve the review that will some how decreases the spam reviews cuz admins could just delete it and no points will be givin

1 Like

This topic was automatically closed after 4 days. New replies are no longer allowed.