Reputation: 3162
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;
}
?>
Upvotes: 1
Views: 2364
Reputation: 7675
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.
Upvotes: 4
Reputation: 3666
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");
Upvotes: 0