By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

How to generate events in php (Server side)

P: 4
Hello
I would ask if there is any possibility to generate events in php
I mean generate it on server side
Exemple:
If (cond1) and (cond2)
{ send email to user
}

cond1 and cond2 exists in DB so I think it is kind of script that
should be always in standby
Thanks
Aug 21 '08 #1
Share this Question
Share on Google+
8 Replies


Markus
Expert 5K+
P: 6,050
I have little to zero understanding of what you're talking about (it is nearly 2:30 am, though).

How to generate events? Could you provide an example please?
Aug 21 '08 #2

dlite922
Expert 100+
P: 1,584
Hello
I would ask if there is any possibility to generate events in php
I mean generate it on server side
Exemple:
If (cond1) and (cond2)
{ send email to user
}

cond1 and cond2 exists in DB so I think it is kind of script that
should be always in standby
Thanks
you'll need to query the database.

do an if statement, and use the mail function or PHPMailer to send the mail.

PHP will not run as a service so you will need to code a file and put it in a crontab or scheduled tasks to run as frequrent as you need, every 5 minutes, hour, day.

Let us know if any questions,



Dan
Aug 21 '08 #3

Atli
Expert 5K+
P: 5,058
Given that your conditions are taken from a database, I assume you have a script that is responsible for updating/inserting those fields?

Would it not be simpler to just have that trigger the mail script?
Aug 21 '08 #4

P: 4
you'll need to query the database.

do an if statement, and use the mail function or PHPMailer to send the mail.

PHP will not run as a service so you will need to code a file and put it in a crontab or scheduled tasks to run as frequrent as you need, every 5 minutes, hour, day.

Let us know if any questions,



Dan
This is a good answer I did not expect that there is such possibility
I’m using cpanel to manage my server and it has only cron jobs and no scheduled tasks (I think) the cron jobs ask for the commend to run??, how can I use it to run a php scrip ?
Thanks

screenshot is attached

Aug 21 '08 #5

P: 4
I have little to zero understanding of what you're talking about (it is nearly 2:30 am, though).

How to generate events? Could you provide an example please?
I have users posting ads and others ”usersalert” are subscribing for new ads so they will receive alert by email if there is cretin number of ads ”n” and, only once a day, so my be that “n” could be reached in any time during the day or, it could take more than one day, so I’m trying to run the scrip automatically in specific time “t” and test if “n” { send email to ”usersalert” } else wait for the next “t”
I hope it is clear now
Aug 21 '08 #6

nathj
Expert 100+
P: 938
I have users posting ads and others ”usersalert” are subscribing for new ads so they will receive alert by email if there is cretin number of ads ”n” and, only once a day, so my be that “n” could be reached in any time during the day or, it could take more than one day, so I’m trying to run the scrip automatically in specific time “t” and test if “n” { send email to ”usersalert” } else wait for the next “t”
I hope it is clear now
It sounds to me like the idea, mentioned earlier, of sending the email when a new ad is inserted is the best solution.

What you could do is set a small counter in another table that keeps track of the number of adverts in a specified period. Then when someone submits the nth advert send the email. Once an email has been sent simply reset the count.

This is simply an enhancement on an earlier posting based on the extra details you have provided.

cheers
nathj
Aug 21 '08 #7

FLEB
P: 30
I think you just need to re-define your problem in more detail. It's not a matter of "sending events"-- it's a matter of...

1.) Determining when to perform the check (in-line with new entries, or perhaps on a daily basis with a cron job).
2.) Getting a set of "trigger" conditions (either hard-coded or from a database)
3.) Querying and retrieving the information from the database that you'll need in order to discover whether the conditions are met
4.) Comparing the database output against the conditions, and
5.) Sending the email

All of these are rather straightforward-- it's just a matter of looking into the individual subjects.
Aug 21 '08 #8

P: 4
It sounds to me like the idea, mentioned earlier, of sending the email when a new ad is inserted is the best solution.

What you could do is set a small counter in another table that keeps track of the number of adverts in a specified period. Then when someone submits the nth advert send the email. Once an email has been sent simply reset the count.

This is simply an enhancement on an earlier posting based on the extra details you have provided.

cheers
nathj
yes this is a solution as well and I thought about it as a last option, but in this case the email con be sent many times a day and I don’t want to be marked as spam
Aug 22 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.