我想在 php 中的两台服务器之间传递变量,例如 A 将发送给 B,然后 B 将对此进行处理并将结果传递给 A,然后 A 将根据结果对其进行处理并将结果传递给 B 等等。这是服务器 A 上的代码。它将电子邮件传递给 B 并将结果存储在 $result 中。
$Email = $_POST['email'];
$postdata="&email=$Email";
$useragent= "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" ;
$ch = curl_init("http://www.gguproject.hostoi.com/handler.php");
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); //set our user agent
curl_setopt($ch, CURLOPT_POST, 1); //set how many paramaters
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); //set data to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result= curl_exec ($ch); //execute and get the results
curl_close ($ch);
这是服务器 B 上的代码。我无法将存储在 $row 中的查询结果传回服务器 A。
<?php
require_once('database_connection.php') ;
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$error = array();
$email = $_POST['email'];
if(!empty($email))
{
$check;
$query_check_credentials = "SELECT * FROM members WHERE (Email='$email') AND Activation IS NULL";
$result_check_credentials = mysqli_query($dbc, $query_check_credentials);
if(!$result_check_credentials)
{
print 3;
}
if (@mysqli_num_rows($result_check_credentials) == 1)//if Query is successfull
{ // A match was made.
$row= mysqli_fetch_array($result_check_credentials, MYSQLI_ASSOC);//Assign the result of this query to SESSION Global Variable
print 2;
$POST['name']=$row['Username'];
}
else
{
print 1;
}
}
?>