无法将PHP变量传递给Epayment网站的隐藏输入

时间:2018-06-22 01:05:23

标签: php html hidden-field payment-processing website-payment-pro

这是电子付款提交表单(HTML + PHP)。它显示了一个获取$Amount的字段。 该表单($amount)将发布到电子支付网站。我试图将$Amount传递给 <input type="hidden" name="amount" value="<?php echo $Amount; ?>" >。(仅在<input type="hidden" name="amount" value="3000.0" >时有效。)

  
    

错误:

  
     

HTTP状态404-/ b2cDemo / eng / payment / null

     
    

类型状态报告

         

消息/ b2cDemo / eng / payment / null

         

说明所请求的资源不可用。

  

这里有问题吗?

第二,可以在我的源代码(HTML)中显示这些商家信息吗?有安全问题吗?

<input type="hidden" name="merchantId" value="13213123">
<input type="hidden" name="amount" value="<?php echo $Amount; ?>" >
<input type="hidden" name="orderRef" value="12313221">
<input type="hidden" name="currCode" value="3213123" >

......

// Define variables and initialize with empty values
$Amount = "";
$Amount_err ="";

if ($_SERVER["REQUEST_METHOD"] == "POST") {...
     // Validate Amount
        $input_Amount = trim($_POST["Amount"]);
        if (empty($input_Amount)) {
            $Amount_err = "Please enter the amount.";
        } elseif (!ctype_digit($input_Amount)) {
            $Amount_err = 'Please enter a positive integer value.';
        } else {
            $Amount = $input_Amount;
        }

    .....
         <form name="Epayment" method="post" action=" a EPayment sites">

    <input type="hidden" name="merchantId" value="....">//fixed code
    <input type="hidden" name="amount" value="<?php echo $Amount; ?>" >
    <input type="hidden" name="orderRef" value="...">
    <input type="hidden" name="currCode" value="..." >

    ......

         <div class="form-group <?php echo (!empty($Amount_err)) ? 'has-error' : ''; ?>">                             
    <label>Amount</label>                    
    <input list="Amount" name="Amount"  multiple class="form-control"> 
       <datalist id="Amount" >
        <option value="100">
        <option value="300">
        <option value="500">
        <option value="1000">
      </datalist>  
    <span class="help-block"><?php echo $Amount_err; ?></span>
     </div>

1 个答案:

答案 0 :(得分:1)

大写很重要。你有

<input type="hidden" name="amount" value="<?php echo $Amount; ?>" >

但是尝试通过以下方式访问它:

$input_Amount = trim($_POST["Amount"]);

您需要将html name属性更改为"Amount" ,或将您的$_POST更改为$_POST["amount"]