我想POST数据发送到指定的外部URL像http://www.example.com/catchPostData.php,其中catchPostData.php看起来是这样的:如何发送POST数据到外部URL并打开目标URL
<?php
echo $_POST['somedata'];
?>
并打开此带有我发送的数据的网址。
我试过使用cURL,但它从给定的URL返回,我想呆在那里!
有人可以帮我吗?
我想POST数据发送到指定的外部URL像http://www.example.com/catchPostData.php,其中catchPostData.php看起来是这样的:如何发送POST数据到外部URL并打开目标URL
<?php
echo $_POST['somedata'];
?>
并打开此带有我发送的数据的网址。
我试过使用cURL,但它从给定的URL返回,我想呆在那里!
有人可以帮我吗?
我认为你在寻找这样的事情:PHP Redirect with POST data
您将需要第二个页面,该职位数据提交到一个完全不同的URL。
你可以用的document.ready功能
$.post({
url: "you_page.php",
type: "POST",
data:{formId:form_id},
success: function (data){
}
});
使用您将需要两个页面:一个页面输入时会被重定向输入到外部URL的第二页。因为你的代码看起来像这样:
page1:
<form method="post" action="./page2.php">
<input type="hidden" name="somedata" value="yourData">
<input type="submit" name="submit" />
</form>
page2:
//you can create an array contains your posted data
//if you are dealing with multiple values
$array = array("somedata"=>$_POST['somedata']);
//create a url variable that will store all values
//since you are going to send them as part of a single url
$url="";
//if you are posting more than one value you will need to loop
//through each one - not necessary if you are sending a single value
foreach($array as $key=>$value){
$url .=$key."=".urlencode($value)."&";
}
header("http://www.example.com/catchPostData.php?$url");
谢谢你的回答,但一切都是这样的:1.按钮在第一页上单击 - >按钮执行功能,收集所需数据 - >通过POST发送数据时没有任何形式 - >外部页面捕获数据并使用它们来填充一些字段 – bbbb
它好吗...高兴地帮助 – awsmketchup
或者你可以尝试ajax后。您需要关心跨域问题。 –