开发者

Validate DATA - jQuery/Ajax (PHP)

I have a javascript that gets the value from 2 SELECT tags, and at last it takes those two values and multiply them.

The script looks like this:

<script type="text/javascript" charset="utf-8"> 
  function displayVals() {
  var exposureValue = $("#mark").val();
  if(exposureValue == 1){
      exposureValue = <?php echo $sdata['ad_cost_micro']; ?>;
  }
  if(exposureValue == 2)开发者_如何学运维{
      exposureValue = <?php echo $sdata['ad_cost_mini']; ?>;
  }
  if(exposureValue == 3){
      exposureValue = <?php echo $sdata['ad_cost_standard']; ?>;
  }
  if(exposureValue == 4){
      exposureValue = <?php echo $sdata['ad_cost_extended']; ?>;
  }
  var clickValue = $("#series").val();
  var totalValue = exposureValue*clickValue;
  $("#price").html("<span style='font-size:22px;color:#3A8913;text-align:center;font-weight:bold;'>$" + totalValue + "</span>");

  jQuery('#p').val(exposureValue*clickValue);

  }

     $("select").change(displayVals);
        displayVals();      
        </script> 

As you can see, the totalValue is added to a hidden INPUT with ID="p".

My question is how can I secure the value of id="p", so it's not possible to do a INJECTION or change the post data or something.

Thanks.


How can I secure the value of id="p", so it's not possible to do a INJECTION or change the post data or something.

You can't. It will always be possible to change the data on client side.

You will need to protect your server-side logic against manipulations, like for example checking whether the values posted make sense.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜