chris
chris

Reputation: 67

Cron job to check date in a database and send a notification

I have a user who will input the date for the next event. It is saved in the format yyyy-mm-dd hh:mm:ss (eg: 2013-06-09 00:00:00) in a MySQL database. How can I write a cron job that sends a notification to the user 3 days in advance about an upcoming event?

Upvotes: 0

Views: 1228

Answers (1)

Mischa
Mischa

Reputation: 43298

You can achieve this in two steps:

  1. You have to write a PHP script that checks in your database if there is an event coming up three days from now and if so, which user in your database created that event. If there's an event, the script sends a reminder email to the user.
  2. In cron you create a task that runs the above mentioned script once a day.

Now that you know the steps, please try to figure out the implementation yourself.

Upvotes: 2

Related Questions