views:

209

answers:

5

hi

i am doing a project where i need to notify a user through email if his account has expired, that is when a user signsup his sign up date and expire date is inserted into the database

now what i need to do is , i need to fire a function when the users expire date is passed and send an email notifying user about the expiration of his account . and this needs to be done automatically through the function .

how can i achieve this ?

A: 

Write a cron job (running as often as you think appropriate) to call a script (possibly PHP CLI) that does a select for all expired accounts and mails them. And what does this have to do with JavaScript?

Matthew Flaschen
+1  A: 

The simplest thing to do is create a basic cron job that runs on a regular interval (like hourly or daily) that runs a PHP script that queries the database for any newly expired users and then emails them.

Ben Hughes
+1  A: 

You can have a cronjob that runs every hour or so (or quicker if you need to). This cronjob would run a PHP script that gets a list of all expired accounts and sends emails to them.

Here's a tutorial on how to use crontab.

Here is a SO question on Cronjob and PHP

Ólafur Waage
A: 

Probably the easiest way to do this would be using either at or cron. Either one of these could be set up to call a PHP or whatever script at the time of expiration, or it could be just run once an hour, each time checking if there are any newly expired entries.

A less efficient approach would be to have the header or footer script of your pages to check the database every time any page is loaded, but I would not recommend this approach unless you absolutely can't use cron or at.

Mark Rushakoff
A: 

By the way, if you are not using a unix / linux system but a Windows one, you could use Scheduled Tasks and call a script.

nairdaen