2

I want to send the POST data to the given external url like http://www.example.com/catchPostData.php, where the catchPostData.php looks like this:

<?php
echo $_POST['somedata'];
?>

and open this url with the data I've send.

I've tryed to use cURL, but it returns from the given url, and I want to stay there!

Can anybody help me with this?

4

3 回答 3

1

我想你正在寻找这样的东西:PHP Redirect with POST data

您将需要第二个页面,该页面将发布数据提交到完全不同的 url。

于 2013-08-01T12:33:27.040 回答
-2

您将需要两页:一页用于输入,第二页将输入重定向到外部 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");
于 2013-08-01T12:54:40.600 回答
-4

您可以使用 document.ready 功能

$.post({
         url: "you_page.php",
         type: "POST",
         data:{formId:form_id},
         success: function (data){
         }
 });
于 2013-08-01T12:36:06.973 回答