2013-10-10 33 views
0

timerecording.php需要$_POST['$currentyear']$_POST['$currentmonth'] 這兩個值來執行一些代碼。當我提出的「edit.php」與隱藏輸入其發送2個值的「timerecording.php」頁面表單這一切都工作正常。使用cURL發送POST數據並使用php標頭位置執行

但是我遇到了麻煩,因爲我想調用header('Location: ' . $url);在「edit.php」裏面的一個特殊功能後重定向,並得到相同的結果,就像我使用表單輸入的解決方案一樣。

如果我想訪問「edit.php」文件在網絡瀏覽器 - 的側向載荷和負載,直到超時。但我沒有收到任何錯誤。

這裏是 「edit.php」 代碼:

$currentyear = 2013; 
$currentmonth = 10; 

$datatopost = array (
"year" => $currentyear, 
"month" => $currentmonth 
); 


$url = "timerecording.php"; 

$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $datatopost); 
curl_exec($ch); 
curl_close($ch); 
$url = curl_getinfo($ch , CURLINFO_EFFECTIVE_URL); 
header('Location: ' . $url); 
exit; 

回答

0

什麼* curl_getinfo *返回???

這個問題時,同一頁面重新加載由於multipal次header('Location: ' . $url);如果網址指向同一網絡資源情況。