I try to save data from a FORM to file. But when 'submit' to external URL my script doesn't see $_POST array
. How to save $_POST
which I send not receive.
I can save $_POST
data I received (I sent to my script and save as 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
.
So my customer stays on my page but should be redirected to payment page with $_POST
data.
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. (it works well , but i dont have saved $_POST in my file) How to save $_POST without sending data to my server/script ?