C#应用程序从php接收数据

时间:2018-06-17 23:34:38

标签: c# php

我想从php收到 收到成功 消息,但我收到了页面来源!

C#代码

using (WebClient wc = new WebClient())
            {
                NameValueCollection students = new NameValueCollection();
                {
                    students.Add("sID", "6");
                    students.Add("sName", "anas");
                    students.Add("sMajor", "prog");
                    String response = Encoding.UTF8.GetString(wc.UploadValues(url, students));
                    students.Clear();
                }

            }

PHP代码

if(isset($_POST['sID']) && isset($_POST['sName']) && isset($_POST['sMajor']))
{
    echo "Received Successfully";

    $stID = $_POST['sID'];
    $stName = $_POST['sName'];
    $stMajor = $_POST['sMajor'];
    $insertQuery = "insert into myTable (ID,stName,stMajor) values ('".$stID."','".$stName."','".$stMajor."')";
    $InsertQ   = mysqli_query($Connection, $insertQuery);

}

1 个答案:

答案 0 :(得分:0)

请在更换网址后尝试以下代码

x = new int[2];