0
我使用下面的代碼將值從一個頁面發佈到另一個頁面,但不知道爲什麼由於某些原因不會發布這些值。任何人都可以幫我糾正下面的代碼,謝謝。PHP將數據從一個頁面發佈到另一頁
<?php
$postdata = http_build_query(
array(
'destinationId' => 'E5322331-EB43-4C45-B5B1-00E455401676',
'keywords' => 'Rambouillet, France'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://dev.ther8server.com/hotel-search/go/rambouillet-france', false, $context);
header('Location:https://dev.ther8server.com/hotel-search/go/rambouillet-france');
?>
您可以使用頭重定向到該頁面。這會使用file_get_contents創建一個完全獨立的請求。 – Steve
您是否期待此代碼將您重定向到您發佈到的頁面並能夠調試發佈的數據? 'stream_context_create'更像是一個捲曲調用。如果您試圖在頁面之間創建持久數據,請嘗試使用會話變量。 –
我想從這個頁面傳輸數據到另一個頁面沒有自動重定向我使用'header Location'來實現重定向。 – lock