Hi all,
it is possible to post value data into another server?
server A -------->> server B
the data that i want to post is :
Name: John Doe
Address : 123 example
code from server A :
http://serverA.com/post.php
PHP Code:
<?
$url = "http://www.serverA.com/post.php";
$Name="John Doe";
$Address="123 example";
$postdata = "Name=$Name&Address=$Address";
$useragent= "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" ;
$ch = curl_init();
//set some cookie details up (depending on the site)
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); //set our user agent
curl_setopt($ch, CURLOPT_POST, 1); //set how many paramaters
curl_setopt($ch, CURLOPT_URL,$url); //set the url we want to use
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); //set data to post
$result= curl_exec ($ch); //execute and get the results
curl_close ($ch);
print $result; //display the reuslt
?>
Code server B to get the result:
http://serverB.com/get.php
PHP Code:
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$Name =$_GET["Name"];
$Address=$_GET["Address"];
$postdata = $_GET["postdata"];
$curlopt="
Name = $Name \n
Address = $Address \n
";
print $name;
print $Address;
Print $postdata;
?>
Notice: Undefined index: Name in /home/cybeszw7/public_html/get.php on line 4
Notice: Undefined index: Address in /home/cybeszw7/public_html/get.php on line 5
Notice: Undefined variable: postdata in /home/cybeszw7/public_html/get.php on line 6
the variable that post from server cannt read in server B
what should i do to write in server A and Server B?????