我有一个页面。我需要在自己的页面上获取内容。奇特的是,仅当提交按钮的值保持原样时,页面才会返回正确的信息。所以当我制作一个表格时
<form action="http://mydestinationpage.php" method="POST">
<input name="rid" type="TEXT"><br>
<input name="submit" type="SUBMIT">
</form>
返回正确的结果。但是当我手动发送带有"rid"
作为查询的帖子数据时,无法检索到正确的数据。所以我的问题是,我如何使用上面的表单通过 php 获取文件内容。
<?php
$query = $_GET['query'];
$postdata = http_build_query(array(
'rid' => $query
));
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
echo file_get_contents('mydestinationpage.php', false, $context);
?>
这就是我尝试这样做的方式,它没有给出预期的结果。
尝试将提交名称和值添加到 POST 数据数组中。
$postdata = http_build_query(
array(
'rid' => $query,
'submit' => ''
)
);
我猜也许目标脚本正在寻找 $_POST['submit'],也许是一个值。