I am working on an website where users will have to pay a small fee to create an account, and having an account will give them access to all of the features of the website for a certain amount of time, lets say 6 months.
Right now, I am using php to create user accounts using a mysql database to store user account info, and users can freely login/out for free, for an unlimited amount of time.
My question is, how would I go about setting a time limit on every account created, and once expired, give users the option to re-new their memebership?
why don’t you simply add an expired column in the user table and compare it with current date before you allow login – if this date has expired just redirect to a payment page to renew the membership?
You can also use this date to show “remaining days” for the active members and start showing payment link in the last few days or so.
I have always used DATETIME as column type to store the dates infor.
Have a look at MySQL date and time functions at http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html For example: The following query selects all rows with a date_col value from within the last 30 days:
What you need in your case is the following query to make memberships inactive –