1

I'm looking for a simple solution for paid memberships on my website.

Basically all I need is a mysql value to change. (Changing account type.) I know you can use Paypal IPN to do this easily.

The problem is after x months the account needs to be changed back. What is the best way to do this? Do I have to run code every day to check expiry times? Or is there something easier?

Raptor
  • 53,206
  • 45
  • 230
  • 366
Rai
  • 138
  • 1
  • 9

1 Answers1

6

This wholly depends on whether you need it to be 100% accurate in your database or not.

If the only time you care about expired accounts is when the person is trying to use your service, I'd just perform the check at an appropriate time (say on logon).

If you need it to be accurate (to the day) I'd look at using cron or a cron-like system to do your database update during off-peak times.

hafichuk
  • 10,351
  • 10
  • 38
  • 53
  • I need it to be accurate. Is it possible to do a cron job without cPanel or something like that? Also, do you know any good tutorials for learning about cron jobs? – Rai Jan 04 '13 at 03:51
  • 2
    [Here](http://www.thesitewizard.com/general/set-cron-job.shtml) is a good overview and tutorial about cron jobs/crontab. It may be a little outdated but still applies for the most part. – troytc Jan 04 '13 at 03:55
  • 1
    That depends on how you access your system. If you have root ssh access to the server, then you can edit the crontab directly. If you don't then you need to rely on some cron-like system, like cPanel. – hafichuk Jan 04 '13 at 03:55
  • IF you are unable to use cron jobs, and you know you have someone visiting the site every day, it's possible to run a query once per visit of a user that will check all the entries. However, this method isn't too efficient when you have a large amount of visitors at the same time. – Felix Guo Jan 04 '13 at 03:58
  • You *could* use a 3rd party to trigger your crons for you. Google "online cron service" and you'll find a bunch. You'd have to write a php page that they would call. The downsides to this is that the script is public and can be abused. – hafichuk Jan 04 '13 at 03:58
  • I'm currently running my website locally on my Windows computer. (Wamp) So I think I'll have to wait until I get a web server to do this. Thanks for the quick replies! :D – Rai Jan 04 '13 at 04:09
  • 2
    http://stackoverflow.com/questions/3237186/how-to-test-a-cron-job-in-local-server-like-wamp should help for local development/testing then. – hafichuk Jan 04 '13 at 04:10
  • 1
    Certainly. The link describes that you use windows scheduler instead of cron to trigger the execution of your update script. There's lots of other tools that you can install and use as well. – hafichuk Jan 04 '13 at 13:55