dsfdsf48652 2011-04-23 11:18
浏览 216
已采纳

PHP脚本POST信息并重定向到另一个页面

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;
}
?>
  • 写回答

2条回答 默认 最新

  • duanlujiaji10335 2011-04-23 11:30
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题