0

Not sure how to explain as i'm not familiar with this, but i have a code that submits payment informations to a gateway, but now it uses _GET i think as the submit path incl. the details of the form.

Such as: gateway.com/?values

I wan't the form to submit this details with _POST and i'm not sure on what i need to change in the code as i think it's very simple, and therefore wanted to run it over by you guys to see if you can point me in the right direction.

A fraction of the code would be the following.

$query['amount'] = number_format((float) $_POST['total'], 2, '.', '');
$query['currency'] = $_POST['currency_code'];

$query_string = http_build_query($query);

Header('Location: http://domain.com/gateway.php?' . $query_string);
Jack Johnson
  • 593
  • 4
  • 11
  • 23
  • possible duplicate: [How do I send a POST request with PHP?](http://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php) – hynner Apr 08 '15 at 17:23
  • You *cannot* trigger a client-side redirect with POST vars, It is only possible with GET. – Sammitch Apr 08 '15 at 18:02

1 Answers1

0

you can use curl

solution with curl :

$query['amount'] = number_format((float) $_POST['total'], 2, '.', '');
$query['currency'] = $_POST['currency_code'];

$url = "http://domain.com/gateway.php"; 
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $query);
curl_exec($handle);

without curl:

$query['amount'] = number_format((float) $_POST['total'], 2, '.', '');
$query['currency'] = $_POST['currency_code'];
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($query),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

for second part of answer you can Refer to this question as well

Community
  • 1
  • 1
A.B
  • 20,110
  • 3
  • 37
  • 71