<?php
// define sample data array for return
$data= ['hospital'=>'phrae',
'php'=>'7.3.13',
'server'=>'apache',
];
// save data from mobile to logfile in server
// please change file permission (linux) to 777
$file=fopen("data.log","w"); // log file, same path of php
fwrite($file,file_get_contents('php://input')); // all request data save to log file
fclose($file); // close file when write complete
if($_POST["hospital"]!=""){ $data["hospital"]=$_POST["hospital"];} // if android had fill data in textbox, store to $data["hospital"]
$data["php"]=$_SERVER['SERVER_SOFTWARE']; // store server info to $data["php"]
$data["agent"]=$_SERVER['HTTP_USER_AGENT']; // store client android browser agent to $data["agent"]
$json=json_encode($data); // encode $data array to json
header("Access-Control-Allow-Origin: *"); // set header prepare for send back to android
header("Content-Type: application/json; charset=UTF-8"); // set type of data to json and use utf-8 charset
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
echo $json; // Reply data to android