2017-05-09 61 views
0

無法在php.i中使用此方法發佈值,並且希望發佈後值到另一頁的頁面。無法將值發佈到php中的其他頁面?使用網址?

header("location:http://webpage.com/retry.php?amount=".$amount); 
+0

嘗試'的var_dump($ _ REQUEST);您retry.php' – hungrykoala

+0

那你想幹什麼?獲得'金額'的價值? – Swellar

+0

要在'URL'中獲取某些東西的值,請使用'$ _GET'。我認爲你正在使用基於標題 – Swellar

回答

0

你不能簡單POST從PHP文件中的數據到另一個PHP文件使用header()。你需要使用一個函數/ API調用cURL

<?php 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL,"http://www.example.com/tester.php"); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, 
      "postvar1=value1&postvar2=value2&postvar3=value3"); 

// in real life you should use something like: 
// curl_setopt($ch, CURLOPT_POSTFIELDS, 
//   http_build_query(array('postvar1' => 'value1'))); 

// receive server response ... 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$server_output = curl_exec ($ch); 

curl_close ($ch); 

// further processing .... 
if ($server_output == "OK") { ... } else { ... } 

?> 

如果你不能每次都寫這個大的代碼和調試錯誤,我recommened您使用UniREST客戶對這項工作。它很簡單,直接,輕便,爲我們做的工作。

下載UniREST from here

0

嘗試這個

if(trim($amount)!=''){ // Check if amount is not empty. 
    // Redirect to page 
    header("location:http://webpage.com/retry.php?amount=".$amount); 
} 
+0

Serioulsy?這口氣是錯誤的。您無法使用'header('Location:blahblahblah')'發送POST請求。 – xXAlphaManXx

+0

其實你可以。 OP可能正在傳遞一個空變量 – Akintunde007

+0

是的,你可以做到這一點 –

相關問題