Forum Moderators: coopster

Message Too Old, No Replies

subscription to terminate after the allotted time

database setup

         

louiseB

8:32 am on Apr 4, 2004 (gmt 0)

10+ Year Member



I was wondering how to go about creating a signup - login
system of which can be dated so if a person signs up for 3 months the subscription will terminate after the allotted time.

I have had minimum php experience with newsletter scripts, forum customising etc. and would love any kinds of leads on this idea :)

Regards,
LouiseB

bigm

7:10 am on Apr 5, 2004 (gmt 0)

10+ Year Member



I would write the expiry date into the database when the user is created and then check this date against the current date at every login.

when the dates match the membership period has expired, and the user can renew his membership.

bigM

louiseB

7:27 am on Apr 5, 2004 (gmt 0)

10+ Year Member



Thanks for your input bigM. I am however, shy of PHP scripting don't know where to start in placing this script for date checking. I think I may have to delve deeper into the learning curve. It is quite steep for me atm. Could this just be added to an existing login db or would the db have to be created from scratch? ie. a general forum have the date chk ref added to it or not?

Thank you for your info :)

httpwebwitch

4:16 pm on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm dealing with the same kind of logic right now on my own project.

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

louiseB

6:09 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



Cheers httpwebwitch, I'll give your idea a go :)

Thank you for the detailed info, I think it should be usable with the db I have atm.

Much appreciated!
LouiseB