dongzhan1570 2015-06-29 17:46
浏览 47

PayPal捐款按钮表格在提交表格内

I have a need to submit form with specific values by clicking submit button. When clicking submit button I want to be redirected to PayPal where asked for donation. After submitting donation I need to redirect customer back to my website where form with values are submitted and shown to customer. But right now I`m stuck. If I press submit button after paying or canceling donation nothing happens with entered values in my primary form with title and website. My Code looks like this:


    <form action="adding.php" method="post" enctype='multipart/form-data'>
        <table>
        <tr>
            <td class="abc">
                <p id="insert">Title:*</p><br>
                <input type="text" name="title" class="abcd"  value="<?php echo $title; ?>" />
            </td>
            <td class="abc">
                <p id="insert">Website:*</p><br>
                <input type="text" name="website" class="abcd" value="<?php echo $website; ?>" />
            </td>
        </tr>
        </table>
        <input type="submit" value="Submit" id="submit" name="submit" />
    </form>

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
        <input type="hidden" name="cmd" value="_s-xclick">
        <input type="hidden" name="hosted_button_id" value="EJJ5RT9MEEJSC">
        <input type="image" src="http://localhost/www/images/submit.png" id="submit" name="submit" border="0" alt="PayPal - The safer, easier way to pay online!">
        <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    </form>

    <?php
        $sql2 = "INSERT INTO `www` (title, website)
        VALUES ('$title', '$website')";
    ?>
    <?php 
        if (isset($_POST['submit'])) {

            $con = mysql_connect("localhost","root","");
            if (!$con){
            exit("Can not connect: " . mysql_error());
        }
        mysql_select_db("www",$con);            
    ?>
    <?php           
    if ((strlen($title) < 3) or (strlen($title) > 15)) {
        echo "<h1 id='top'>Title must be between 3 and 15 characters long!</h1>";
    } else if (filter_var($website, FILTER_VALIDATE_URL) === false) {
        echo("<h1 id='top'>Website: Please enter a valid website to your wish.</h1>");
    }
    else
    {   
        mysql_query($sql2,$con);
        mysql_close($con);

        header("Location:index.php");           
    }
    ?>
  • 写回答

1条回答 默认 最新

  • douzhi19900102 2015-06-29 19:34
    关注

    first add the database related code in adding.php, where the first form submits the values, and in this form (adding.php), use javascript to submit the paypal donation form

    i.e call a javascript function on page unload: call_paypal.

    function call_paypal() { document.getElementById("paypal_frm").submit();}

    < form action="https://www.paypal.com/cgi-bin/webscr" id="paypal_frm" method="post" target="_top" >

    < /form >

    It's done...

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line