hi how can i have it setup where a user can only send 2 gifts a day on my website?

many thanks

Every time the user sends a gift, you can insert a record of that into a tracking table. Then you can retrieve all gifts that were sent in the past 24 hours. E.g. SELECT COUNT(id) FROM gifts WHERE time_sent < 24 hours.
Then if the count is two or more, disable the sending of gifts.

So you select all gifts that were sent in the past 24 hours, and then you count those results. If the user has not yet sent 2 gifts, he may send another one :). Hope this helps?

Member Avatar for diafol

You can approach this in two ways - the way suggested - where you look for two gifts within the last 24 hours OR you look for number of gifts THAT day (midnight to midnight). I prefer the first method as local midnight will be different to server midnight for many of your users. Also the first method allows for countdown until next gift. The second method really wouldn't make much sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.