PHP Tutorials and Scripts   




Title: Interserver Communications    Marked Cool    (Review this resource)
Author: davidlo
Posted On: 2004-12-20
Category: Home > PHP Tutorials

Popularity: 1 points out of 10    

Description: How to let two separated HTTP and PHP systems communicate with each other without using sockets.

Total Hits: 1800     Total Votes: 0     Total Points: 0 (1 reviews)    

Page Navigation:  [1]  [2]  [3]


Interserver Communications




Part III

To make it actually do something is quite simple-you have it act on the information it receives. To this end, you only need some conditionals in the client.php and/or requester.php file. For example, you could have the client file update a MySQL table based on the request, or you could have the requesting server update it's own MySQL tables according to the feedback received. Here is an example:

requester.php:
<?php 
$str=file_get_contents("http://server/client.php?user=user&
	password=password&action=check&id=log.txt");
if($str == "exists") 
{
	//perform something. of what? i have no clue 
}
?>
client.php:
<?php 
if(!($_GET['user']=="user" && $_GET['password']=="password"))
      exit();
//terminate it on the spot
//if not dead yet, proceed
if($_GET['action']=="check") {
     if(
file_exists($_GET['id']))
         echo
"exists" ;
     else
         echo
"mia" ; }
?>
 

If need be, you can also have the requester run another query on the client (for example, to check if anything else needs to be updated) There are limitless possibilies of how you can use the requester and the client, of which those are out of the scope of this tutorial.

Page Navigation:  [1]  [2]  [3]



© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.