PHP而不是<;表格>;在HTML中从脚本发送表单并停留在重定向页面上?

PHP而不是<;表格>;在HTML中从脚本发送表单并停留在重定向页面上?,php,html,post,curl,paypal,Php,Html,Post,Curl,Paypal,现在我的表格中有以下代码: <form action="https://www.paypal.com/cgi-bin/webscr" target="_BLANK" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="paypal@********.com"> <inp

现在我的表格中有以下代码:

<form action="https://www.paypal.com/cgi-bin/webscr" target="_BLANK" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="paypal@********.com">
    <input type="hidden" name="lc" value="SE">
    <input type="hidden" name="item_name" value="Premium Membership">
    <input type="hidden" name="custom" value="<?php echo $session_user_id; ?>">
    <input type="hidden" name="item_number" value="1">
    <input type="hidden" name="amount" value="0.80">
    <input type="hidden" name="currency_code" value="SEK">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="no_shipping" value="1">
    <input type="hidden" name="notify_url" value="http://*******.com/eta/ipn.php">
    <input type="hidden" name="return" value="http://********.com/purchase/thanks">
    <input type="hidden" name="cancel_return" value="http://*******.com">
    <input type="hidden" name="rm" value="0">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
我可以从我的functions.php中的帖子中获取值,并将它们存储在变量中,例如
$pp\u cmd,$pp\u business
。问题是我需要以某种方式使用所有这些变量,并将它们作为隐藏的输入和表单post方法发送到
action=”https://www.paypal.com/cgi-bin/webscr“
并停留在该页面继续在PayPal页面上,就像我只是使用默认表单操作PayPal页面一样

怎么做

这可以通过直接的PHP或带有cURL的PHP实现吗?如果是的话,你能提供一些基本的代码,包括至少两个第一个隐藏的输入,这样我就可以自己完成它了吗

更新:在我的位置上,使用AJAX不是一个选项。脚本必须在不使用JavaScript的情况下工作。我正在寻找这个问题的PHP解决方案。

function curl_post($url, array $post = NULL, array $options = array())
{
    $defaults = array(
        CURLOPT_POST => 1,
        CURLOPT_HEADER => 0,
        CURLOPT_URL => $url,
        CURLOPT_FRESH_CONNECT => 1,
        CURLOPT_RETURNTRANSFER => 0,
        CURLOPT_FORBID_REUSE => 1,
        CURLOPT_TIMEOUT => 4,
        CURLOPT_POSTFIELDS => http_build_query($post)
    );

    $ch = curl_init();
    curl_setopt_array($ch, ($options + $defaults));
    if( ! $result = curl_exec($ch))
    {
        trigger_error(curl_error($ch));
    }
    curl_close($ch);
    return $result;
}
curl_post("https://www.paypal.com/cgi-bin/webscr",$_POST);

更新:将CURLOPT_RETURNTRANSFER更改为0。OP希望导航到paypal页面,而不仅仅是post。

为什么不提交一个问题,即没有OK标记,阻止默认设置,并将表单ajax添加到编辑脚本中。返回更新后的数据(JSON格式良好),并使用新数据更新表单,设置OK标记,然后提交表单。或者在处理页面上,使用新数据重新创建表单,并自动提交(到paypal)@Waygood这在我的位置上不是一个选项。即使javascript关闭,它也必须工作。更新建议提交到您自己的脚本,然后自动向paypal提交新表单(对于非javascript,您需要将提交按钮更改为->重定向到paypal)@Waygood能否请您添加一个答案,并解释如何使用php自动提交带有抓取值的表单?因为这正是我在问题中要问的;)它应该在零件
中???这里有什么代码?
在我的函数中。php@Waygood你知道如何做到这一点吗?;(它不会重定向到
https://www.paypal.com/cgi-bin/webscr
。它将重新加载并与表单保持在同一页面上;(。为什么?我尝试在
curl\u post()https://www.paypal.com/cgi-bin/webscr“,$\u POST);
所以它是
curl\u POST(”https://www.paypal.com/cgi-bin/webscr“,$\u POST);退出();
但现在它是白色屏幕,仍然与我的表单在同一页上。没有发生重定向,只是因为退出()屏幕是白色的;知道为什么重定向到paypal url不起作用吗?我尝试了不同的url,但仍然不起作用;(.如何将浏览器重定向到包含帖子信息的新URL?一定有什么东西阻止了重定向。你知道可能是什么吗?将CURLOPT_RETURNTRANSFER更改为0
function curl_post($url, array $post = NULL, array $options = array())
{
    $defaults = array(
        CURLOPT_POST => 1,
        CURLOPT_HEADER => 0,
        CURLOPT_URL => $url,
        CURLOPT_FRESH_CONNECT => 1,
        CURLOPT_RETURNTRANSFER => 0,
        CURLOPT_FORBID_REUSE => 1,
        CURLOPT_TIMEOUT => 4,
        CURLOPT_POSTFIELDS => http_build_query($post)
    );

    $ch = curl_init();
    curl_setopt_array($ch, ($options + $defaults));
    if( ! $result = curl_exec($ch))
    {
        trigger_error(curl_error($ch));
    }
    curl_close($ch);
    return $result;
}
curl_post("https://www.paypal.com/cgi-bin/webscr",$_POST);