Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating CRON Job that needs to use PHP and HTML and even Javascipt

Posted on 2011-03-05
4
Medium Priority
?
579 Views
Last Modified: 2013-12-25
Dear Experts,

I want to use the cron functionality to run a tasks every hour, but from reading a few articles here I understand that cron can not execute HTML as it is not like viewing the page in a web browser. Because one of my scripts is updating multiple mysql rows, I need to use html and a submit button which can not be excecuted by CRON. I have looked at this article about using CGI bin to store the scripts that I can use CRON to execute the script in the CGI bin. Here is the link

Any help with this I would be very grateful. I need to include a submit button in the script file that will submit automatically when the page loads. Now I can achieve this with javascript but I do not think this will work as Javascript is not a server side language. ( can CGI execute javascript) or is there a way to have the html or php automatically submit the form once the page has loaded.

Again any suggestion that could help would be really helpful as I have almost no knowledge of CGI bin's capabilities or how to submit a form automatically once the page loads without using javascript.

many thanks as always for your help
0
Comment
Question by:Lightwalker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35045201
You don't need HTML.  PHP can probably do all of it.  If you can read the information, the script can update your MySQL without a form on a page.
0
 
LVL 5

Expert Comment

by:dcesari
ID: 35055026
You can also work client side and use cron to start a client request with the wget program (usually available on linux distributions), simulating what you would do by hand with the browser, the only difficulty here is to reconstruct the exact query string that is passed to the server, especially if you use a POST method, you may find this information by looking at the webserver log, or reconstruct by looking at the HTML form. The command to be launched by cron would look more or less like this:

wget "http://myserver.com/myscript.php" --post-data="key1=data1&key2=data2"

wget allows also to pass authentication information or cookies, with some additional effort.
0
 
LVL 2

Expert Comment

by:adeelshahid
ID: 35057021
try using wget inside your cron job,

and in the php script use a iframe to call the file where you want the html, php to execute.
0
 
LVL 5

Accepted Solution

by:
palanee83 earned 2000 total points
ID: 35065851
As far as i know, you can not execute the JS from server side using CRON.

If you want to submit the form using POST / GET method using PHP, You can do it uing CURL library. You can do this with few lines for code.

#Example for HTTP GET

http://www.php.net/manual/en/function.curl-exec.php


#Example for HTTP POST (Collect all the form variable and construct an associative array)

http://davidwalsh.name/execute-http-post-php-curl

Note; Before you use this library, make sure CURL is enabled on your web server. You can check this with the help of phpinfo() function.



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question