Cannot pass the PHP variable to the hidden input for Epayment website

1.3k Views Asked by At

This is a E-payment submit form (HTML+PHP). It shows a field that gets the $Amount . This form ($amount) will post to a E-payment website .I tried to pass the $Amount to <input type="hidden" name="amount" value="<?php echo $Amount; ?>" > .(It works when <input type="hidden" name="amount" value="3000.0" > .)

Error:

HTTP Status 404 - /b2cDemo/eng/payment/null

type Status report

message /b2cDemo/eng/payment/null

description The requested resource is not available.

Any problems here?

Secondly , is it okay to show these merchant info in my source code(HTML)? Any security issues?

<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

There are 1 best solutions below

3
On

Capitalization matters. You have

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

Yet try to access it via:

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

You need to change your html name attribute to "Amount" or your $_POST to $_POST["amount"]