Forum Moderators: coopster
I have had minimum php experience with newsletter scripts, forum customising etc. and would love any kinds of leads on this idea :)
Regards,
LouiseB
Thank you for your info :)
You probably already have a script that checks if the name and password is correct. In that same script, add another condition: that the current date falls between the start date and end date of the subscription.
On my site, when someone signs in as a new member, they get a 14-day free trial. So, in the database I set the "start" as now, and the "end" as 14 days from now. If someone buys a subscription, I just move the "end" date forward by however many days/months they paid for. That method works for me.
I keep all the (encrypted) pwds and subscriptions together in the database, so it's no problem to check two things at once:
[in pidgin SQL]
SELECT yaya from Members WHERE pwd='pwd' and uid='uid' AND start<now AND end>now
if numrows(result)>0 // then the user may enter!
I receved some good advice on this project from a veteran database architect - she suggested this method. You want to keep that start and end date for each user - you definitely don't want to be creating and deleting some kind of "permission" as though it's a switch being turned on or off.
If you want a more robust system, you might even keep a separate entry for each subscription payment, with start/end dates for them. Then any one user might have multuple entries like:
User "httpwebwitch"
subscription 0 = from May to August 2003
subscription 1 = from September 2003 to January 2004
subscription 2 = from January to March 2004
Though it is possible to end up with overlapping subscriptions (you must be careful with the date logic!) This method has the added advantage of good record-keeping, and still works with the start<now<end method described above.
good luck!
httpwebwitch