0

I've tried looking for a solution to this issue for a few days now and am getting quite confused.

Aim:

To have a PHP server ("Server A") communicate directly to another PHP server ("Server B") when Server A is visited by user. It then sends a query string to Server B to add in to Server B's database.

Full story:

A visitor will visit Server A and register to their website, as part of their registration Server A will write to Server A's database with all the visitors information. At this point I'd like Server A to load a .php file on Server B and send a query string with it, for example: http://example.com/api/add.php?name=Craig&age=21&key=32r932r9832yr813hr813rh1389ry13r7y31r. Server B, having a PHP file requested from it, will take the variables and run the script on add.php (take the variables and add it to it's database).

Important note: I don't want the client machine to know this, initially I wanted to use JQUERY but realised this sends the request from the client machine and not the server directly.

What is the best way to do this?

Many thanks in advance!

Craig

3
  • 1
    Maybe looking for cURL? php.net/manual/en/book.curl.php Commented Jun 13, 2012 at 16:50
  • What you need is a webservice, which can be implemented via protocols like REST or SOAP. Or just call a script via cURL, as @jeremyharris suggested. Commented Jun 13, 2012 at 16:54
  • I had looked at cURL but didn't understand it... how would I load a URL with a query string using it? Commented Jun 13, 2012 at 20:28

1 Answer 1

1

Learn cURL. Here is an example to get you started:

<?php

$ch = curl_init('http://example.com/api/add.php?name=Craig&age=21&key=32r932r9832yr813hr813rh1389ry13r7y31r');
curl_setopt($ch, CURLOPT_HEADER, 0);

$response = curl_exec($ch);

curl_close($ch);

?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.