-1

My requirement: I need to get data from database and submit the values on some other website form after each 2 min .

I am planning to do this by creating as similar form and populating values from db then submit it using document.getElementById("webform-form").submit();

It works fine if I manually run the url

but it doesn't work when I submit it using cron job.

Cronjob is ignoring this state of form submission. I want to know whether it is possible to do it using cronjob and form submission. If not, please suggest me how should I proceed.

Thanks in advance

Satish Sharma
  • 9,217
  • 6
  • 24
  • 49
Pritesh
  • 59
  • 6

2 Answers2

0

You could use a "headless" browser like PhantomJS to submit the form and then put the PhantomJS script on a cron - which shouldn't be that hard.

You can find a sample form submit for Phantom here and then you could just put it in the cron like this:

*/2 * * * * phantomjs you-form-submit-script.js
Community
  • 1
  • 1
Bogdan Constantinescu
  • 5,196
  • 4
  • 37
  • 50
0

Using the method you've described you need your page to be loaded by real browser and to be run by javascript in it.

I think you want to do a POST request directly from your PHP script without being loaded by browser. It can be done by CURL. You can find some examples on this site.

Community
  • 1
  • 1
Lukas Kral
  • 847
  • 13
  • 21