日期:2014-05-17  浏览次数:20428 次

客户端socket发送http POST请求可以触发服务端PHP页面的isset吗?
我在客户端使用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-Alive

testname=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的内容吗?

------解决方案--------------------
不会!
因为你没有发送 submit 这个变量
------解决方案--------------------
PHP code

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