Triggering a PHP script via web page hits
It occurred to me that the Expiry Checker could be triggered by web page hits. Typically, PHP scripts are activated when a user submits a form over the web, however in this case some mechanism would be needed to trigger a PHP script without the user's knowledge. I remembered that when I tutored on the Global Communications Techniques unit, Jon Selig mentioned in one of his lab exercises that a cgi script can be invoked by calling it as if it was an image file. So I tried embedding this into a web page and it worked:
<img src="http://www.sbu.ac.uk/php-cgiwrap/~bushm/send-email.php3"
width="0" height="0" border="0" alt="">
|
I also read somewhere that another way to do it would be to have a
web page consisting of two frames, with the second frame taking up zero
screen space - its purpose is to invoke the PHP screen in such a way
that the user remains oblivious.
But then it occurred to me that it might be tricky to avoid an email getting sent every time a page was hit, which could potentially be annoying for the recipient of the emails! I decided that a cron job would probably be better, because the Expiry Checker program/script could be guaranteed to run exactly once per day.
|
|