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.

Recommended Answers

All 7 Replies

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.

Member Avatar for diafol

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

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?

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.

Member Avatar for diafol

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.

how to make a static alaram in php it warns fr certain time

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.