2011-04-23 5 views
1

다른 서버로 트랜잭션 결과를 POST해야하고 이후 다른 페이지로 리디렉션해야하는 PHP 지불 스크립트를 만들고 있습니다.정보를 POST하고 다른 페이지로 리디렉션하는 PHP 스크립트

기본적으로 스크립트의 트랜잭션 값 SUCCES는 www.domain.com/transaction.php에 게시해야하며 이후에는 "confirmation.php"로 리디렉션되어야합니다.

누군가 어떻게 말해 줄 수 있습니까?

편집 :

이것은 내가 찾고 있었던 것입니다 : 당신은 당신의 양식의 작업 속성에 포스트 URL이 필요

<?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; 
} 
?> 

답변

4

사용할 수를 여기에 단편이다 PHP에서 리디렉션 페이지에 대한 다음 코드를

header('Location:confirmation.php'); 

또는 다음과 같은 코드를 시도 할 수 있습니다 :

$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); 

그 코드를 사용하면 PHP로 데이터를 게시 할 수 있습니다.

+1

고마워. 이것은 제가 찾고 있던 해결책입니다 ... – Andrei

0

. 당신의 transaction.php 파일에서

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

, 당신은 제출 된 데이터에 대해 수행 할 무엇 이건, 및 리디렉션을 위해, 당신이 그렇게 같은 header 기능을 사용할 수 있습니다 : <?php header("Location: confirmation.php");

+0

정보를 다른 PHP 페이지에 자동으로 게시하려면 PHP 코드가 필요합니다. 나는 양식을 사용하는 방법을 알고 ... – Andrei

관련 문제