Block database entry for 6 months
I have a MySql 4.1 database using PHP 4 where people can signup using email address as username. It also has a datetime field that records the signup date. After a user signup, I would like to stop that prson from signing up again for 6 months, them let them re-enter again.
What's the best way to approch this? Cookies? In the database?
Definitely not cookies. Users regularly delete them.
I'd suggest you do it in the database. But why 6 months? Why not make the email address unique so that it can only sign up once?
If you need the six months, then each time they sign up, sql search by the email address, sorting by the sign up date, descending. Read the first record, calculate the difference between the date and today, and reject if less than 6 months.
This is a 14 day trial subscription to an online news service. My boss wants to limit "serial trialers". Let them have a taste, but not the whole meal, and not too often.
Ok. That's fair.
Presumably, you're already using the signup date to calculate their 14 days.
Use the same signup date to calculate 180 days. There are a few different ways php can do that, depending on your version. (The php manual should give you all you need on that.)
If today is less than the signup+180, then reject. If not, then allow them to sign up again.
The other issue you need to consider is whether you create a new record for each sign-up, or whether you just update the signup date if the record exists. I'd do the latter, but I'd include a field in the file that counts the number of times they've signed up for the trial.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread