1

I am making a PHP payment script that needs to POST transaction results to another server and after that to redirect to another page.

Basicly the script have the transaction value SUCCES that needs to be POSTED to www.domain.com/transaction.php and after that to be redirected to "confirmation.php".

Can someone tell me how can I do that?

EDIT:

This is what I was looking for:

<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
?>
Andrei RRR
  • 3,068
  • 16
  • 44
  • 75

2 Answers2

4

you can use the following code for redirect page in php :

   header('Location:confirmation.php');

or you can try with the following code :

$postdata = http_build_query(
    array(
        'var1' => 'here your data',
        'var2' => 'here your data'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://www.domain.com/transaction.php', false, $context);

with that code you can post the your data with php.

Ariful Islam
  • 7,639
  • 7
  • 36
  • 54
0

You need the post URL in your form's action property. Here's a snippet:

<form name="form" id="form" method="post" action="http://www.domain.com/transaction.php">..</form>

In your transaction.php file, do whatever you want to do with the submitted data, and for redirecting, you can use the header function like so: <?php header("Location: confirmation.php");

Ali
  • 3,568
  • 2
  • 24
  • 31