tags:

views:

602

answers:

3

I want to mail after 6 hours automatically to my user who hasn't fully completed form on my website.

Help Me

+1  A: 

You will need to create the php script that does the checking and mailing, and then set the cron job like the following

/path/to/php -q /home/username/public_html/mycheckingscript.php

Obviously you will need to adjust the first path to point to your php binary, and the second path to point to the full location of your checking & mailing script.

Mark
A: 

I don't think you want to set the cron up using php. Instead write a php script and then have cron execute that script every hour or so. This would be something that is going to be dependent on your operating system.

For linux, here is the manpage for using crontab.

jW
+7  A: 

Use crontab -e to edit the cron table for your account.

In the crontab, put an entry something like...

0,10,20,30,40,50 * * * * /usr/bin/wget -O - -q http://path.to/cron.handler.php

or the equivalent

*/10 * * * * /usr/bin/wget -O - -q http://path.to/cron.handler.php

...which will run the cron handler php file every 10 minutes using wget (there are other options as well, and you may need to edit the command appropriately). (Note: you don't want to just run it every 6 hours, because then if someone happened to fill out the form right after it ran, it wouldn't have been 6 hours since they filled it out next time it runs, so you'd end up with 10-11 hour gaps.)

Then in your PHP file, find users who BOTH (a) haven't fully completed the form for at least 6 hours and (b) haven't been emailed yet. Send them an email, and mark them as having been emailed.

Amber
Ack - comment parser issue: `*/10 * * * *` format might be worth a mention.
gnarf
Yep, I'll add a mention of it.
Amber