我有一个用WPF C#编写的exe应用。
,我想通过php数据传递给网站,并且 我想将这些数据传递到数据库中。
Web服务是用php编写的。
我怎么做这个php代码?也不确定我的C#...
这是c#代码:
public static void AddNewUserArrayJson(List<UsersExcelInfo> LUEI)
{
string ParameterURL = "?Action=AddNewUserArray";
string URL = CConsts.BASE_URL + ParameterURL;
var json = JsonConvert.SerializeObject(LUEI);
var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
{
// Do the actual request and await the response
var httpResponse = httpClient.PostAsync(URL, httpContent)
}
}
这是我尝试编写的php代码
if ($Action=="AddNewUserArray")
{
$_POST = json_decode(file_get_contents('php://input'), true);
$id = explode(",",$_POST['id']);
$FirstName = explode(",",$_POST['FirstName']);
$LastName = explode(",",$_POST['LastName']);
$Phone = explode(",", $_POST['Phone']);
$TypeOfUser = explode(",",$_POST['TypeOfUser']);
$Gender = explode(",",$_POST['Gender']);
$ExpiredDate = explode(",",$_POST['ExpiredDate']);
$Favor = explode(",",$_POST['Favor']);
$Remarks = explode(",", $_POST['Remarks']);
$Email = explode(",", $_POST['Email']);
$DateOfBirth = explode(",",$_POST['DateOfBirth']);
$RegestraionDancer = explode(",", $_POST['RegestraionDancer']);
$length = count($id);
for ($i = 0; $i < $length; $i++)
{
$query="INSERT INTO `Users` (`id`, `FirstName`, `LastName`, `Phone`, `TypeOfUser`, `Gender`, `ExpiredDate`, `Favor`, `Remarks`, `Email`, `DateOfBirth`, `RegestraionDancer`) VALUES ('$id[$i]', '$FirstName[$i]', '$LastName[$i]', '$Phone[$i]', '$TypeOfUser[$i]', '$Gender[$i]', '$ExpiredDate[$i]', '$Favor[$i]', '$Remarks[$i]', '$Email[$i]', '$DateOfBirth[$i]', '$RegestraionDancer[$i]')";
$result = mysqli_query($mysqli,$query);
}
}
很乐意提供帮助...