php POST variable with headers

守給你的承諾、 提交于 2019-12-24 01:44:35

问题


This is the code:

header("Location: checkout/transactionCompleted.php?id=".$transactionId);

Then I use $_GET['id'] to get the value. So far so good.

Question: How can I do that by POSTING the variable instead and without using session??

Thanks,

George


回答1:


$post_data = 'id='.$transactionId;
$content_length = strlen($post_data);

header('POST checkout/transactionCompleted.php');
header('Host: localhost');
header('Connection: close');
header('Content-type: application/x-www-form-urlencoded');
header('Content-length: ' . $content_length);
header('');
header($post_data);



回答2:


$http_request  = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= $req;

I think that you have to fill such form, and then send it.



来源:https://stackoverflow.com/questions/6300081/php-post-variable-with-headers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!