mysql - Using PHP & cron how can i inform a user that he has got 15 days more left to pay his amount?Get the solution ↓↓↓
DueDate Table structure
my query here is how to check automatically in php that a user has 15 days prior from the table and inform a user that he has got 15 days more left to pay his amount. 15 days from the dueDate as shown in the table
so if the user due date is
2011-11-17 he has to be informed 15 day prior that is on
how to achieve this using php to inform automatically ?
You need a script run by CRON scheduled daily, probably on 00:01am every day.
You have to create a cron tab file, a plain text file and load it on your server. A cron tab file look like this
1 0 * * * php /path/to/your/script.php
Above file will run script.php on 00:01 am daily.
In script.php, you do the 15 days look-up thingy.
There should be a CRON editor on your server's cpanel. You might not even need to write your own cron tab file, they usually have a GUI editor. If not
1 0 * * * php /path/to/your/script.php is your only content.
1 0 * * * means run the following command every day at 00:01am.
php means execute the following PHP file and
/path/to/your/script.php specifies which PHP file to run.
Remember that path mush be absolute path starting from the root of your server because CRON is not the same as running on web environment.
On script.php, you do the query (see other answers), get the list of people who are 15 days away from their due date and do the notification.
You can test your script.php by running directly from web browser before putting it into cron too.
You can use the date time functions of mysql.
SELECT instalmentsDetailsID FROM DueDate WHERE DATE_SUB(dueDate, INTERVAL 15 DAY) >= NOW()
SELECT * FROM DueDate WHERE DATE_ADD(DueDate , INTERVAL -15 DAY) <= NOW()
That will give you all the items that are currently in their notice period
Share solution ↓
Link To Answer People are also looking for solutions of the problem: script cache:clear returned with error code 255
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.