开发者

getting the value from a textbox in php

i am trying to create a donate page. the hole page is php,

there is a textbox that hold the amount value which should be send via hidden input with the url to the the payment gateway. i have tryed many time but it is not working. i am still a beginner in this could any one please help me in fixing my code here

   <div class="donate">
   <?php
        $amount = $_REQUEST['amount'];
        $txtCurrency = 840;
        $txtAmount   = number_format($amount, 2, '.', '');
        echo $amount;       
        $key     = "TEST";
                    $txthttp     = "http://test.com/you.php";

    ?> 
    <form action="payment.php" name="form1">
 开发者_开发百科       <input type="text" id="amount">
        <input type="submit">
            <input type="hidden" name="txtAmount" value="<?= $txtAmount; ?>">
            <input type="hidden" name="txthttp" value="<?= $txthttp; ?>">
            <input type="hidden" name="signature" value="<?= $key; ?>">
    </form>
   </div>


In general, you should avoid using $_REQUEST when you can use $_GET or $_POST. $_REQUEST allows variables to be set by either an HTTP GET or POST, which can pose a security risk, since your site will presumably use one or the other. With that said, here's what I would do:

  1. Add method="post" to your form tag.
  2. Access the input elements by looking at $_POST['txtAmount'], $_POST['txthttp'], etc.

In general, you can view all variables set in the POST by doing this:

var_dump($_POST);


You can access these values from payment.php with $_POST['txtAmount'], $_POST['txthttp'], $_POST['signature']. How you handle them will be up to your code. I see that you used the $_REQUEST array, which will work, however I believe it's better form to be specific and use the $_POST array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜