简体   繁体   English

完成/提交表格,然后重定向到 PayPal

[英]Complete/Submit form then redirect to PayPal

I have a form that a user fill out.我有一个用户填写的表格。 In the form I have 4 payment categories: $10, $20, $30, $40 that are displayed as check boxes.在表单中,我有 4 个付款类别:显示为复选框的 10 美元、20 美元、30 美元、40 美元。 What I am trying to do is, when the user checks one of the check boxes and then submits the forms he is is then views a PayPal button.我想要做的是,当用户选中其中一个复选框,然后提交他所在的表单时,就会查看一个 PayPal 按钮。 When clicked he is redirected to a PayPal page.单击后,他将被重定向到 PayPal 页面。 For example, If I check $10 check box then I am redirected to a PayPal page with the $10.例如,如果我选中 $10 复选框,那么我将被重定向到带有 $10 的 PayPal 页面。 My problem right now is that I am not able to redirect.我现在的问题是我无法重定向。 When I submit I do not see the PayPal button.当我提交时,我没有看到 PayPal 按钮。 Has someone dealt with something like this before?以前有人处理过这样的事情吗? Thanks.谢谢。 Here is a basic code: Page input:这是一个基本代码: 页面输入:

<input type="checkbox" name="1" value="$10" >
<input type="checkbox" name="2" value="$20" >
<input type="checkbox" name="3" value="$30" >
<input type="checkbox" name="4" value="$40" >

Page submit:页面提交:

// category     
        $category = $_POST['category']; 

        if ($category == "1") {
            $show = "1, $10";
            $pay = "$10";
        } else if ($category == "2") {
            $show = "2, $20";
            $pay = "$20";
        } else if ($category == "3") {
            $show = "3, $30";
            $pay = "$30";
        } else if ($category == "4") {
            $show = "4, $40";
            $pay = "$40";}

 <form action="https://www.paypal.com/cgi-bin/webscr" name="form2"    method="post" target="_blank" style="padding:0px">
            2. Pay by Credit Card (PayPal)
            <? include ("pages/categories/$category.php");  ?>
            </form>

And then category pages: I have a folder called "categories" inside this page I have 4 pages with these 4 payment categories.然后是类别页面:我在此页面中有一个名为“类别”的文件夹,我有 4 个页面,其中包含这 4 个付款类别。 On each page I have pasted a PayPal button code as follows.在每个页面上,我都粘贴了一个 PayPal 按钮代码,如下所示。

Your HTML and PHP don't match.您的 HTML 和 PHP 不匹配。 Your form has the name of the inputs as 1, 2, 3, 4. Your PHP is looking for a form field name "category".您的表单的输入名称为 1、2、3、4。您的 PHP 正在寻找表单字段名称“类别”。

<input type="checkbox" name="category" value="1">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM