0

Hi to All,

Can anyone show me a sample alarm script using php or javascript? The alarm was base on the record at the database. I mean, for example I have records that have overdue, the user is the one who state the overdue. For example, the user input his overdue is after one 1 he saves the record, so I want the system will give an alarm after 1 hour.

Thanks in advance.

5
Contributors
7
Replies
18
Views
6 Years
Discussion Span
Last Post by diafol
0

Unless I an mistaken the questions you have to answer first are what script determines that an alarm condition exists and where does the alarm out put go (if the user is no longer accessing the page for example)? Personally I would generate and email from a script running in cron (every 2 minutes or so) and send the email to the user or whom ever is supposed to get the notice.

0

running a cron every 2 minutes? bit extreme? why not have a js script run an ajax update?

0

Hi lyrico, could you explain a little more about what you are trying to achieve? For example, do you want the alarm to be directed to the user or to a system administrator?

0

Ahm ok. So I'll try to elaborate as much as I can ^^,

The situation goes like this.

I have a script where I can save records (stock number, item, hours before expire,). Now for example, I save the record at exactly 4:00 PM and then in the "hours before expire", I input 4 hrs. So I want to have a script that send a mail stating the this item is expire at exactly 8:00 PM.

0

You need a post_time field as well, otherwise the alarm will not now when to fire. I suggest using a unix timestamp and post_time as an integer field. You can test for the expiry time:

$expiry_time = ($no_hours * 3600) + $post_time;

When do you want the email sent - immediately? If so, you can use a date() function to change the new unix timestamp ($expiry_time) into any format you want.

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.