我在客户端使用SOCKET发送HTTP的POST请求POST /send.php HTTP/1.1
Host: www.temp.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6)
Gecko/20050225 Firefox/1.0.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 6
Connection: Keep-Alivetestname=a
www.temp.com/send.php页面如下<form id="send" name="send" method="post" action="send.php">
<input name="testname" type="text" id="testname" />
<input type="submit" name="submit" id="submit" value="提交" />
</form><?php
if(isset($_POST['submit'])){
if($_POST['testname']=='a'){
//判断处理
}
}
?>我的疑问是:客户端发送HTTP请求头后,php页面会执行isset($_POST['submit'])并判断testname的内容吗?

解决方案 »

  1.   

    不会!
    因为你没有发送 submit 这个变量
      

  2.   


    那应该怎么发送submit的变量(怎么发送HTTP请求头的时候触发按钮点击?)或者我把PHP改成如下
    <?php
    if($_POST['testname']=='a'){
    //判断处理
    }
    ?>
    可以么?
      

  3.   

    你是怎么送HTTP请求的 ? 代码是什么?
      

  4.   


    POST /send.php HTTP/1.1
    Host: www.temp.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6)
    Gecko/20050225 Firefox/1.0.1
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 6
    Connection: Keep-Alivetestname=a我先用VB测试的,用WINSOCK控件,将上面的信息用Winsock.SendData发送
    <?php
    if($_POST['testname']=='a'){
    //判断处理
    }
    ?>
    用这样的PHP代码是不是可以直接取到值了?
      

  5.   


    <?php
    //保存post请求的数据
    file_put_contents("log.txt", json_encode($_POST));
    ?>
    看看log.txt就知道了