help with triggering a PHP script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yachtsox
Forum Newbie
Posts: 2
Joined: Fri Jul 30, 2010 4:17 am

help with triggering a PHP script

Post 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
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: help with triggering a PHP script

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help with triggering a PHP script

Post 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.
d8p
Forum Newbie
Posts: 4
Joined: Mon Aug 02, 2010 5:38 am

Re: help with triggering a PHP script

Post by d8p »

Maybe using the JavaScript function window.onbeforeunload() could solve your problem?
yachtsox
Forum Newbie
Posts: 2
Joined: Fri Jul 30, 2010 4:17 am

Re: help with triggering a PHP script

Post by yachtsox »

Cheers Jake, cron was exactly what I was after - works great!

Thanks ;D
Post Reply