我尝试使用PHP Post Request inside a POST Request,以为它可能对我有用。我给出了以下代码:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
我有两个文件index.php
和index2.php
,它们在同一个目录下。当我打开页面时,在我的error.log
文件中出现以下错误:
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP致命错误:在/var/www/testing1/index.php的第5行调用未定义的函数curl_init()
我想要创建一个预订表单并发送POST请求。然后我想要处理POST值并再次将POST请求发送到PayPal。