I have to send emails automatically on weekend basis by checking database values without form submission or button using codeigniter.is there any idea. someone please help
-
1what you want is CRON... – ArtisticPhoenix Jan 26 '18 at 08:19
-
Thank u, I'm a beginner in php and new to 'CRON' .. I'm checking more about this. If you have any recommended reference site, mention please – Mia Jan 26 '18 at 08:33
-
I can say this, think of CRON as running the script via the command line. Which is what it does, it's useful for testing to be able to run it that way. All CRON does is run your code ( by the command line ) at a set time or interval. – ArtisticPhoenix Jan 26 '18 at 11:14
1 Answers
PHP call with CRON
If what you want is run a php script (that send emails or do what ever you want) automatically, use CRON on your server (if you are on Linux of course) by editing crontab with this command :
crontab -e
Add this line in the end of the file and save it :
0 8 * * 0 /usr/bin/php /home/toto/test.php
This example execute the script test.php in toto home directory every sunday at 8 AM.
More info on how to use cron here : Execute PHP script in cron job
PHP call from MySQL Trigger
There is another way to call a PHP script automatically every sunday or when ever you want, by creating a Trigger on MySQL. Especially if you can't use CRON, on Windows for example (WAMPP). You will use the sys_eval
commande in your Trigger procedure.
sys_eval("C:/xampp/php/php.exe -f "C:/xampp/htdocs/phpFile.php");
Here is a good example for this solution : https://stackoverflow.com/a/2763238/2282880
Note : On Windows Server, you could use scheduled tasks to ru the php.exe app too. But never tried.

- 3,558
- 3
- 41
- 51