如何获取method为post的表单返回的页面? 没明白LZ意思 不知道用$_POST['']可不可以~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果用 post的表单,应该有一个提交动作,或者用一个事件触发js。如 function TJsub() { document.form1.action ="test.php?action=setup settings.submit(); } 不好意思,上面的js应该是:function TJsub() { document.form1.action ="test.php?action=setup from1.submit(); } 我的最终目的是要调用别人的查询页面把结果插到我的网页里.-----------------------Why not get the contents of the result page directly??? 自己构造一个HTTP请求,然后将数据POST过去应该没有问题,下面是测试代码。基本原理就是这个了。详细的HTTP协议可以读一下 RFC 2616。下面的代码执行以后能在返回的字符中发现“<tr><td colspan=2 align=center style="color: red ;">验证码不匹配,请重新输入验证码</td></tr>”,说明数据已经被正常的POST到baidu去了function read_http_post($host, $file, $uid, $pwd){ if (!$fp=fsockopen($host,80, $errno, $errstr, 15)) return false; $post = "tpl=&tpl_ok=&skip_ok=&aid=0&need_pay=&need_coin=0&pay_method=0&u=&next_target=&return_method=&more_param=&return_type=&username=$uid&password=$pwd&verifycode=0338&Submit=+%B5%C7%C2%BC+"; $out = "POST /$file HTTP/1.1\r\n"; $out .= "Host: $host\r\n"; $len = strlen($post); $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Referer: http://passport.baidu.com/?login\r\n"; $out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon;)\r\n"; $out .= "Content-Length: $len\r\n"; $out .= "Connection: Keep-Alive\r\n"; $out .= "Cookie: BAIDUID=F6255B5C19AB4E25E923A4B00DFD7F16; BDUSS=JUTFdxOVJvM25BbHRXYXpxZ0lmVHBIMVdPa2ZRYWl-emliTDNMNlJGYkFNdTFFQUFBQUFBJCQAAAAAAAAAAAAAAACAHPwAbGFuc3oyMDUwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMClxUTApcVENU; PASSPORTRETRYSTRING=1153803768%7C1153804122%7C1153804129\r\n\r\n"; $out .= $post; fwrite($fp, $out); $line = ""; while (!feof($fp)) { $line .= fgets($fp, 2048); if(preg_match("/<\/HTML>/", $line)) break; } fclose($fp); return $line;}echo read_http_post("passport.baidu.com", "?login", "baidu", "baidu"); 请举几个关于应用抽象类比较典型的案例 找网站后台程序人员 在线等给分~PHP克癃问题! 请教PHP中exec的问题 一个原始的提问,PHP新闻发布中的对文本框内容处理的步骤------------大家讨论下自己的步骤 初学php,请问php开发环境我应该用什么环境呢?! 给另一个网页传值传不过去阿? 能否访问两个MYSQL数据库服务器中的数据库 php url重定向,不能用<meta>及 PHP调试求助 如何使字体加亮 请教表单问题?
如 function TJsub() {
document.form1.action ="test.php?action=setup
settings.submit();
}
function TJsub() {
document.form1.action ="test.php?action=setup
from1.submit();
}
-----------------------Why not get the contents of the result page directly???
详细的HTTP协议可以读一下 RFC 2616。下面的代码执行以后能在返回的字符中发现“<tr><td colspan=2 align=center style="color: red ;">验证码不匹配,请重新输入验证码</td></tr>”,说明数据已经被正常的POST到baidu去了function read_http_post($host, $file, $uid, $pwd)
{
if (!$fp=fsockopen($host,80, $errno, $errstr, 15))
return false;
$post = "tpl=&tpl_ok=&skip_ok=&aid=0&need_pay=&need_coin=0&pay_method=0&u=&next_target=&return_method=&more_param=&return_type=&username=$uid&password=$pwd&verifycode=0338&Submit=+%B5%C7%C2%BC+"; $out = "POST /$file HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$len = strlen($post);
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Referer: http://passport.baidu.com/?login\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon;)\r\n";
$out .= "Content-Length: $len\r\n";
$out .= "Connection: Keep-Alive\r\n";
$out .= "Cookie: BAIDUID=F6255B5C19AB4E25E923A4B00DFD7F16; BDUSS=JUTFdxOVJvM25BbHRXYXpxZ0lmVHBIMVdPa2ZRYWl-emliTDNMNlJGYkFNdTFFQUFBQUFBJCQAAAAAAAAAAAAAAACAHPwAbGFuc3oyMDUwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMClxUTApcVENU; PASSPORTRETRYSTRING=1153803768%7C1153804122%7C1153804129\r\n\r\n";
$out .= $post; fwrite($fp, $out); $line = "";
while (!feof($fp))
{
$line .= fgets($fp, 2048);
if(preg_match("/<\/HTML>/", $line))
break;
} fclose($fp);
return $line;
}echo read_http_post("passport.baidu.com", "?login", "baidu", "baidu");