怎样不使用表单,直接发送post数据?

-神仙- 2004-08-06 02:08:31
RT
...全文
253 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
qingxia 2004-08-06
  • 打赏
  • 举报
回复
呵呵
-神仙- 2004-08-06
  • 打赏
  • 举报
回复
好了
我居然把$_POST写成了$_GET
-神仙- 2004-08-06
  • 打赏
  • 举报
回复
还是
Notice: Undefined index: vendor_id in F:\MyWeb\test\phppost1.php on line 2 Notice: Undefined index: vendor_pwd in F:\MyWeb\test\phppost1.php on line 3
qingxia 2004-08-06
  • 打赏
  • 举报
回复
少写了一行,没指定类型
正确写
$request = "POST ".$url['path']." HTTP/1.1\r\n";
$request .= "Host: ".$url['host']."\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "User-Agent: roastduck Http/1.1\r\n";
$request .= "Accept-Language: zh-cn\r\n";
$request .= "Content-length: ".strlen($content)."\r\n";
$request .= "Connection: Keep-Alive\r\n\r\n";
$request .= $content;
-神仙- 2004-08-06
  • 打赏
  • 举报
回复
一楼的办法接受不到数据啊

还有,我是要截获输出的,所以不能用js来POST
-神仙- 2004-08-06
  • 打赏
  • 举报
回复
倒~~
能用GET我还用POST干嘛
okdw 2004-08-06
  • 打赏
  • 举报
回复
不行,那只能假装一下
<form action="a.php" method=post name="theform">
<input type=text name="para" value="5">
</form>

<a href="#" onclick="javascript:theform.submit()">sss</a>
Debian 2004-08-06
  • 打赏
  • 举报
回复
GET
get.php?param=value
qingxia 2004-08-06
  • 打赏
  • 举报
回复
<?
set_time_limit(100);

$data['vendor_id'] = '6B627460656614';
$data['vendor_pwd'] = '63626664725E6B640E';

$url = "http://61.172.197.186/portallogin.aspx";
$url = parse_url($url);

if (!$url) return "couldn't parse url";
if (!isset($url['port'])) { $url['port'] = 80; }
if (!isset($url['query'])) { $url['query'] = ""; }

$fp = fsockopen($url['host'], 80);

if (!$fp)
{
echo "Failed to open socket to $url[host]";
fclose($fp);
exit;
}

$content = "vendor_id=".$data['vendor_id']."&vendor_pwd=".$data['vendor_pwd']."&Submit=%CC%E1%BD%BB";

$request = "POST ".$url['path']." HTTP/1.1\r\n";
$request .= "Host: ".$url['host']."\r\n";
$request .= "User-Agent: roastduck Http/1.1\r\n";
$request .= "Accept-Language: zh-cn\r\n";
$request .= "Content-length: ".strlen($content)."\r\n";
$request .= "Connection: Keep-Alive\r\n\r\n";
$request .= $content;

fputs($fp, $request);

while (!feof ($fp))
{
$tmp .= fgets($fp, 4096);
}
fclose($fp);

echo $tmp;

$fp = fopen('respond.txt','w');
fwrite($fp,$tmp);
fclose($fp);
?>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧