我想使用HTTP Web POST将数据从表单插入服务器。我下面有我的代码,我无法获取 JObject json 的值并将其发送到我的PHP代码中。
a <- table(dataset$group1, dataset$group2)
b <- table(dataset$var1[dataset$group1=='x'])
d <- table(dataset$var1[dataset$group1=='b'])
data.frame(total_count_of_group = c(a[2,2], a[1,1]),
var1_1 = c(b[1], b[2]),
var1_2 = c(d[1], d[2]))
total_count_of_group var1_1 var1_2
1 5 3 2
2 4 2 2
PHP代码:
var caf = entCafNo.Text;
string url = "http://192.168.120.9:7777/TBS/mobile-request.php?Host=" + Constants.hostname + "&Database=" + Constants.database + "&Request=SendCaf";
string contentType = "application/json";
JObject json = new JObject
{
{ "CAF", caf }
};
HttpClient client = new HttpClient();
var response = await client.PostAsync(url, new StringContent(json.ToString(), Encoding.UTF8, contentType));
答案 0 :(得分:1)
使用此代码:
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$caf = $json_obj->CAF;
$sql = "INSERT INTO tblCaf(CAFNo)
VALUES('$caf')";
mysqli_query ($conn, $sql);