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条)

报告相同问题?

悬赏问题

  • ¥20 数学建模数学建模需要
  • ¥15 c语言数据结构实验单链表的删除
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决