Blogs

Blogs

curl

curl is a command line tool which can transfer data from one server to another server using request method like POST,GET, etc.
But User can use mostly POST method to transfer information.

Request Code :

$fields = array('emp_id' => '1','emp_name' => 'nishant','address' => 'surat','email' => 'example@abc.com', 'phone' => '******1010');

$url = 'http://****';  /* Your another server url where you want to transfer data*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

You can get your result using this :

/* get short result */
print_r($result);

/* get full information */
print_r($info);

Server Code :

$emp_id = $_POST['emp_id'];
$emp_name = $_POST['emp_name'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];

/*  You can do your activity Like add, edit, delete, email,etc */