auto submit form using cron job [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
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

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.

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

Related

PHP script run once, even on two machines [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a PHP script basic update script, i want it to run only once, it is running once on a single machine, but when i use two machines and run it at the same time, pressing the buttons at the same time it is running twice, how to solve this?
There's not really enough info here to answer the question definitively, but I'll take a stab at it.
First, my assumptions. You have a web server with a PHP application that shows a web page with a button on it. You load the page on two different computers (or in two different browser windows). When you click the button in one browser, you want to prevent it from running when you click it in the other browser.
You need some flag on the server that:
gets set the first time the button is clicked and your update process is started
is checked the second time the button is clicked (and prevents your update process from running again)
gets unset when the update process finishes.
There are many ways to do this. The simplest if probably creating a file in the filesystem when the button is clicked the first time. More complicated ways of doing this include setting a value in a database or a key value store like Redis.
Edit Highlighted "on the server" because, from the comments above, it sounds like the OP is setting a flag in an HTML element.

How display errors in html without refreshing the form [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
this is the php code im using and want these errors(Echos) to be displayed in the html form without refreshing it after the submit button is clicked
.
THANK YOU
<?php
include 'index.php';
........
if (mysqli_num_rows($num_u) > 0 && mysqli_num_rows($num_e) > 0 ) {
echo "User Already Excist";
}
<html>
Unfortunately, changing page content without refreshing a page isn't possible in PHP. PHP runs when the page loads but once it's finished processing the only way to start the same or a new script is to make a new request. You'll have to use Javascript to execute an ajax request to populate the error.
You need to use JQuery's ajax methods.
They can get data from the server and update your dom on the fly without a page reload.
This is pretty straightforward using Get or Post
JQuery also has some other ajax methods which may be useful as well.
You can check this Create Login Form Using jQuery blog for more details, I hope it's help to you

Sending email using php mail function - Getting slow [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have set up a php function to send email when a button is clicked using isset($_POST['id']).
I am receiving the mail correctly but its takes approximately 8 sec to navigate to the next page.
I know it will take a bit of time to login into mail server and sending the mail.
Is there any way to avoid the latency, e.g. by doing it as a background process?
when button is clicked that time you can call the AJAX, you can set the loader on the page when mail sent that time you can hide the that loader
Well, if it is a background process, you can do it with ajax call.
Ajax is the first answer, but if you want it to be called by server you can just exec('php your_php_code_sending_mail.php param1 param2') ; so the user not even have to load the result page in browser, so you can make your validations in PHP and are not dependant on the user browser. You just need some specific rights, depending on your server configuration.

Can we Use php script in Google Tag Manager [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Just wondering if a php code could be executed via Google Tag manager?
Thanks
No. The Google Tag Manager inserts client-side Javascript. PHP requires a server that is configured for PHP. Inserting a PHP script via GTM would just output the raw PHP code to the browser, it would not execute the code.
If you want to include the results of a PHP Script you would have to run the script on your own server and fetch the results via Javascript as suggested in UncleRicos answer.
I would look at Custom Events in Triggers here: https://support.google.com/tagmanager/answer/6106961?hl=en&ref_topic=3441647&vid=1-635797415927700239-1991783559
You can specify a javascript event that would be called upon a trigger being executed, which in turn could call a routine via ajax (which could be PHP or anything).

How to execute another PHP file? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
My question is: is there a way to execute another php file after HTML form post? I don't want to use header, because i don't want to go to the php page, i only want to execute it.
Clarification:
My i have an addmatch.php, which shows a form where you can add fiels to a table with matches + it shows the table with matches. This PHP page executes the insert.php, which adds data to the SQL database. After adding a field/match, i want to return (i use a header in the insert.php) to the addmatch.php with the updated tabel. So far so good, it works.
But now i my problem: after adding a field, i want to execute another php file. This file, named json.php, is responsible for echoeing json objects of the SQL data. This works. But now my problem is: it only works when i refresh this page after adding a field to the table. But i want to refresh it automatically after adding a field/match on the addmatch.php file WITHOUT open this php file. Is this possible? And how?
Thanks in advance.
if i understand your question .... you may use jquery & ajax . on submit run the ajax code without need to refresh the page .

Categories