2014-09-01 38 views
0

嗨,有沒有辦法使用cURL的形式?像PHP表單一樣的PHP cURL行爲?

比如我有網址mysite.com/curly.php其具有靶向mysite.com/straight.php將顯示,我從curly.php

張貼在這裏的每一個數據捲曲腳本是我的代碼:

$url = "http://mysite.my/curly.php"; 
$curl = curl_init($url); 

curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); 
curl_setopt($curl, CURLOPT_POSTFIELDS, "order_id=123&bill_total=1000000&merchant_id=99999&merchant_name=myname&custName=customer"); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
curl_exec($curl); 

curl_close($curl); 

straight.php

echo $_POST['order_id']; 
echo $_POST['bill_total']; 
echo $_POST['merchant_id']; 
echo $_POST['merchant_name']; 
echo $_POST['customer_name']; 

當我使用header("Location: " . $url);它只顯示我一個空白頁。

編輯: 對於那些不瞭解我想要的東西。 我需要打開我的地址欄上的發佈數據(重定向?)straight.php知道我的意思嗎?

+0

爲什麼使用header(「Location:」。$ url); ?? – 2014-09-01 08:32:52

+0

我想用張貼的數據打開straight.php – Gamma 2014-09-01 08:33:29

+0

你已經寫了這段代碼「header(」Location:「。$ url);」in straight.php right?不起作用 。使用會話來存儲它,並在cUrl執行後打印會話。 – 2014-09-01 08:39:15

回答

0

你不需要使用

header("Location: " . $url); 

的捲曲發佈您的URL參數

使用

$mypage = curl_exec($curl); 
echo $mypage ; 

看到該網址發生了什麼什麼的頁面在帖子後返回