[英]How to save form data before sending to URL
I try to save data from a FORM to file. 我尝试将数据从FORM保存到文件。 But when 'submit' to external URL my script doesn't see
$_POST array
. 但是,当“提交”到外部URL时,我的脚本看不到
$_POST array
。 How to save $_POST
which I send not receive. 如何保存我发送的未收到的
$_POST
。
I can save $_POST
data I received (I sent to my script and save as post_array.txt). 我可以保存收到的
$_POST
数据(已发送到脚本并另存为post_array.txt)。 But I have to send it to external url. 但我必须将其发送到外部网址。 I tried to receive and resend saved
$_POST
using cURL
but I cannot do redirect with $_POST
. 我尝试使用
cURL
接收并重新发送已保存的$_POST
但是无法使用$_POST
进行重定向。 So my customer stays on my page but should be redirected to payment page with $_POST
data. 因此,我的客户停留在我的页面上,但应使用
$_POST
数据重定向到付款页面。
html : <form method="POST" action="cert.php">
php : cert.php
file_put_contents('post_array.txt', $_POST, FILE_APPEND);
$url = 'https://sandbox.przelewy24.pl/trnDirect';
$fields =['p24_merchant_id' => $_POST['p24_merchant_id'],
'p24_session_id' => $_POST['p24_session_id'],
'p24_amount' => $_POST['p24_amount'],
'p24_currency' => $_POST['p24_currency'],
'p24_sign' => md5($_POST['p24_session_id'].'|'.$_POST['p24_merchant_id'].'|'.$_POST['p24_amount'].'|'.$_POST['p24_currency'].'|'.$_POST['p24__sign'])];
//open connection
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
// this cURL dosnt have a redirect option coz it doesnt work for me :(
// execute!
$response = curl_exec($ch);
file_put_contents('response.txt', $response, FILE_APPEND);
// close the connection, release resources used
curl_close($ch);
Because cURL doesnt work as expected i want to direct send $_POST do external page. 因为cURL不能按预期工作,所以我想直接发送$ _POST做外部页面。 (it works well , but i dont have saved $_POST in my file) How to save $_POST without sending data to my server/script ?
(效果很好,但是我没有在文件中保存$ _POST)如何保存$ _POST而无需将数据发送到服务器/脚本?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.