简体   繁体   English

PHP将数据从一页发布到另一页

[英]PHP Post data from one page to another page

I used the following code to post the values from one page to another page but don't know why for some reason the values are not posted. 我使用以下代码将值从一页发布到另一页,但不知道为什么出于某些原因未发布值。 Can anyone help me correcting the below code, thanks. 谁能帮助我更正以下代码,谢谢。

<?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');
?>

This code causes PHP to post a form, get the $result page... and then ignore all that and redirect the client to another page. 此代码使PHP发布表单,获取$ result页面...,然后忽略所有内容并将客户端重定向到另一个页面。

Instead of of the header Location, you just want to echo $result; 您只需要echo $result;而不是标题Location echo $result;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM