Page 1 of 1

help with triggering a PHP script

Posted: Fri Jul 30, 2010 4:43 am
by yachtsox
Hi guys, hoping someone can help point me in the right direction here...

I'm working with a Flash developer to develop an competition page where users can enter multiple rounds of competitions. Each time they enter a competition they'll have an entry added to the db. After they've finished playing we want to send them an email summarizing all the competitions they've just entered.

The problem I have is figuring out how to trigger the script to send the email. eg. the user might play 2 rounds of competitions, and have them both added to the db. They might then browse away from the page without clicking a 'finish playing' button or anything, but we still want to send them the email as they've finished playing.

It's got me stumped as to how to trigger the email without any action from the user? I've got a good knowledge of PHP but definitely am not a guru, so I'm hoping someone can give some tips!


Thanks

Re: help with triggering a PHP script

Posted: Sun Aug 01, 2010 3:21 am
by JakeJ
Check in to cron jobs if you've got a linux based server.

A cron job can trigger a php script. How you want to decide when to send the emails is entirely up to you.

Re: help with triggering a PHP script

Posted: Sun Aug 01, 2010 8:05 am
by superdezign
You could also utilize AJAX to periodically check if the user is still active. Whenever it determines that the user is inactive, notify them.

Re: help with triggering a PHP script

Posted: Mon Aug 02, 2010 6:54 am
by d8p
Maybe using the JavaScript function window.onbeforeunload() could solve your problem?

Re: help with triggering a PHP script

Posted: Mon Aug 09, 2010 4:48 am
by yachtsox
Cheers Jake, cron was exactly what I was after - works great!

Thanks ;D