Submitting a form with a cron job? |
Hey fellas, its me again.
I'm trying to write a cron job for my codeigniter app, but I have now idea where to start. So far, I created a controller called 'cron' with the following: PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); My cron job has to submit form data in a view, and I thought this would help, but I don't think it will work. I can't find any resources online for making cron jobs in codeigniter, so am I on the right track? I know that I need to execute the cron job file itself with a command (I found help here for that), but this is as far as I have gotten. Please help!
To run your code from a cron job, you have to call your controller via the CLI: https://chez14.gitlab.io/codeigniter-doc...l/cli.html
And to submit the form, you can use CURL. You can find a lot of example with Google.
(03-26-2020, 02:15 PM)includebeer Wrote: To run your code from a cron job, you have to call your controller via the CLI: https://chez14.gitlab.io/codeigniter-doc...l/cli.html Thanks a BUNCH! So the CURL should just be sent to the same controller the form is being sent by the view?
If you want to submit a form to another website, use CURL. You will be able to make a POST request and send the fields with their associated values.
But if you want to send a form to your own application, I’m not sure it’s the best way. I don’t see a reason why you would need to use a form when you can just call the model or library you need from the controller.
(03-26-2020, 02:25 PM)includebeer Wrote: If you want to submit a form to another website, use CURL. You will be able to make a POST request and send the fields with their associated values. Thanks for you help! I just tried to run the script, and I got this error: PHP Code: An uncaught Exception was encountered
|
Welcome Guest, Not a member yet? Register Sign In |