Question:
How to send variables over to and remotely execute a script on a different server using PHP?
Chuck
2015-01-18 15:48:31 UTC
Hello,
(I have next to zero experience with PHP, im so sorry).

I have two servers, server A and server B.
I want to send 3 variables over to server B at www.serverB.com/function.php and then execute the function.php using these 3 variables in the script. I just want serverA to send the variables over, execute the script and forget about it. Server B should still be executing the script once Server A has sent the variables and left.
Three answers:
Chris
2015-01-19 02:35:48 UTC
We already answered this. To run a php script on server B, all you need to do is request the script from any other computer. Whether the computer that does the requesting (server A in this case) processes or discards the reply or whether there even is a reply doesn't matter; function.php will run on server B and has access to the GET and POST variables, period.



Running the script on server B is as easy as entering "serverB.com/function.php" in a web browser's address bar and pressing enter, because that will cause the browser to request that URL and thus cause serverB.com to run "function.php".



If you want server A to do the requesting, it needs to request serverB.com/function.php using the HTTP protocol.

One way is to put another PHP script on server A and use cURL in it.

Then you need to run server A's script, again by opening, say, "serverA.com/go.php" in a browser.



Here's a script that will cause a php script on bcchanger.com to run: http://ideone.com/98bjlJ

In line 10, the URL is requested. You can stop at this point, since serverB will now execute the script.
2015-01-18 18:03:37 UTC
That does not work. As soon as the machine navigates away from the script it will stop. you need to set it to post the variables and holde the connection until it receives a completed or failed reply from the other server. You need to write the remote script to return appropriate results for the first server to handle.
just "JR"
2015-01-18 19:17:51 UTC
Maybe you could read the answers we have already given you...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...