Send email automatically with Code Igniter |
[eluser]jimmy90[/eluser]
Hi, I'm very newbie with Code Igniter. I want to create a code for sending email automatically if the car's speed exceeds the speed limit is in the database. Here is my code, Code: <?php Code: <?php Sorry for my bad english. Thank you. ^^
[eluser]pickupman[/eluser]
Your code is very close to working. I would recommend using the following in your model Code: //Change Right now, you are only returning the query object, not a field value. The corrected code will return the result object or FALSE if query fails. I can't tell from your query strings if you might be returning multiple rows or not. You will need to iterate through the result object and process accordingly. Code: $getmail = $this->Send_model->get_mail();
[eluser]jimmy90[/eluser]
Hi, thank you for your help. But for the code that I made, it only works if the user is online or not? ^^
[eluser]pickupman[/eluser]
[quote author="jimmy90" date="1275479945"]Hi, thank you for your help. But for the code that I made, it only works if the user is online or not? ^^[/quote] Sorry, what is this supposed to mean?
[eluser]jimmy90[/eluser]
[quote author="pickupman" date="1275502937"] Sorry, what is this supposed to mean? [/quote] I mean the code that I made, can it executes if the user access the page? ^^
[eluser]pickupman[/eluser]
[quote author="jimmy90" date="1275551161"][quote author="pickupman" date="1275502937"] Sorry, what is this supposed to mean? [/quote] I mean the code that I made, can it executes if the user access the page? ^^[/quote] Yes...just like any other web page. If you are wanting to automatically run the script at a set interval, you will need to setup a crontab.
[eluser]jimmy90[/eluser]
[quote author="pickupman" date="1275552115"] Yes...just like any other web page. If you are wanting to automatically run the script at a set interval, you will need to setup a crontab.[/quote] How can I setup my code into a crontab because I don't really know what cron is? and how it work? ^^
[eluser]Simian Studios[/eluser]
[quote author="jimmy90" date="1275556832"][quote author="pickupman" date="1275552115"] Yes...just like any other web page. If you are wanting to automatically run the script at a set interval, you will need to setup a crontab.[/quote] How can I setup my code into a crontab because I don't really know what cron is? and how it work? ^^[/quote] This link should fill you in on the basics of crontab - http://kb.iu.edu/data/afiz.html You can easily have your cron job execute any script like this: Code: * * * * * curl --silent --compressed http://your.site/send/send_email >/dev/null 2>&1 The above would run your send_email method every minute, but you can change the time settings to get whatever frequency you want.
[eluser]jimmy90[/eluser]
[quote author="Simian Studios" date="1275572103"][quote author="jimmy90" date="1275556832"][quote author="pickupman" date="1275552115"] Yes...just like any other web page. If you are wanting to automatically run the script at a set interval, you will need to setup a crontab.[/quote] How can I setup my code into a crontab because I don't really know what cron is? and how it work? ^^[/quote] This link should fill you in on the basics of crontab - http://kb.iu.edu/data/afiz.html You can easily have your cron job execute any script like this: Code: * * * * * curl --silent --compressed http://your.site/send/send_email >/dev/null 2>&1 The above would run your send_email method every minute, but you can change the time settings to get whatever frequency you want.[/quote] Thank you for your suggestion, it really works. ^^
[eluser]Simian Studios[/eluser]
[quote author="jimmy90" date="1276157673"] Thank you for your suggestion, it really works. ^^[/quote] No problems - it can be a bit daunting the first time you need to set up a cron job but it's simpler than it seems! |
Welcome Guest, Not a member yet? Register Sign In |