无法将值发布到php中的其他页面?使用网址?

问题描述:

无法在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

你不能简单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

尝试这个

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

是的,你可以做到这一点 –