php发送http请求

index.php页面
PHP code

<form method="post" action="test.php">
            类型:<input type="text" id="type" name="type"/><br>
            电话:<input type="text" id="phnum" name="phnum"/><br>
            分机号:<input type="text" id="ext" name="ext"/>
            <input type="submit" id="sub" name="sub" value="提交"/>
        </form>


test.php页面
PHP code

$A=trim(urlencode($_REQUEST['type']));
            $B=trim(urlencode($_REQUEST['phnum']));
            $C=trim(urlencode($_REQUEST['ext']));
            $params = "A=$A&B=$B&C=$C";

            $length = strlen($params);
            $fp = fsockopen("localhost",808,$errno,$errstr,10) or exit($errstr."--->".$errno);
            $header = "GET /CRM/test2.php HTTP/1.1\r\n";
            $header .= "Host:localhost \r\n";
            $header .= "Referer:localhost:808/CRM/test2.php \r\n";
            $header .= "Content-Length: ".$length."\r\n";
            $header .= "Content-Type: text/html \r\n";
            $header .= "Connection: Close\r\n\r\n";
            $header .= $params."\r\n";
            fwrite($fp,$header);
            while (!feof($fp)) {
                echo fgets($fp, 128);
            }
            fclose($fp);


test2.php页面
PHP code

echo $_GET['A']."<br>".$_GET['B']."<br>".$_GET['C'];


我从index.php提交表单后,test.php能够得到提交的数据;
从test.php向test2.php发送http请求后,test2.php得不到数据。
为什么会是这样?难道这种方法不行?请大侠赐教!!

作者: heroblues   发布时间: 2011-01-07

post提交表单要用$_POST,$_REQUEST[]都可以用,$_GET只能用于get方式提交的表单……

作者: lijpwsw   发布时间: 2011-01-07

test.php向test2.php发送请求时是用get方式发送的,和index.php没关系吧?

作者: heroblues   发布时间: 2011-01-07

$params是不是要加个 ?
PHP code

            $A=trim(urlencode($_REQUEST['type']));
            $B=trim(urlencode($_REQUEST['phnum']));
            $C=trim(urlencode($_REQUEST['ext']));
            $params = "?" . "A=$A&B=$B&C=$C";



作者: lijpwsw   发布时间: 2011-01-07

我们项目中现在是基于http://scripts.incutio.com/httpclient/这个工具做http客户端...

你具体情况看不到不好说, 建议打开调试跟踪一下看问题出在哪里才好决定怎么解决

作者: lgg201   发布时间: 2011-01-07

我只要能把参数穿给tets2.php就行

作者: heroblues   发布时间: 2011-01-07

请高人进来看看,该怎么解决啊?!

作者: heroblues   发布时间: 2011-01-07