Php 如何存储id=";getdobtval";进入数据库?
嗨,我想在“输入值属性”中插入基于javascript的额定值 我下面的代码是这样的,当我滚动范围滑块时,它在id=“getdobtval”中显示价格,但当我现在购买时,它不会插入数据库Php 如何存储id=";getdobtval";进入数据库?,php,database,mysqli,Php,Database,Mysqli,嗨,我想在“输入值属性”中插入基于javascript的额定值 我下面的代码是这样的,当我滚动范围滑块时,它在id=“getdobtval”中显示价格,但当我现在购买时,它不会插入数据库 <form action="" method="post"> <input id="slider-bottom" type="text" name="hrate" data-slider-min
<form action="" method="post">
<input id="slider-bottom" type="text" name="hrate" data-slider-min="600" data-slider-max="100000" data-slider-step="1" data-slider-value="600" data-slider-tooltip="show"/>
<output id="getdobtcval" name="getdobtval"></output>
<input type="hidden" name="<?php $_SESSION['sess_user']; ?>">
<input type="submit" name="buynow" >
</form>
我已经更新了我的答案
首先检查检查金额时,该字段是否为空
type=“hidden”
更改为type=“text”
第二次更改插入查询
$sql = "INSERT INTO buy_rate(hrate,hrate_price,in_username)
VALUES('".$h_rate."','".$hrate_price."','".$in_username."')";
在变量中使用串联谢谢,但是id=“getdobtval”这个值是价格,当我在滑块中选择将在id中显示价格的数量时,该价格需要存储,但我现在习惯于隐藏该价格,你能告诉我如何将javascript生成的值放入我想使用javscript将该值插入值字段吗
<?php
if(isset($_POST['buynow'])){
$h_rate = $_POST['hrate'];
$hrate_price = $_POST['getdobtval'];
$in_username = $_SESSION['sess_user'];
$conn = mysqli_connect("localhost", "root", "", "buyrate");
$sql = "INSERT INTO buy_rate(hrate,hrate_price,in_username) VALUES('$h_rate','$hrate_price','$in_username')";
if (mysqli_query($conn, $sql)){
echo "Sucessfully Added";
}else{
echo "error";
}
mysqli_close($conn);
}
?>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#slider-bottom').slider().on('slide', function(ev){
var finalvalue='';
var finalbtvalue='';
var finalbtprice='';
var finalbitvalue='';
finalbtprice= 250;
var newVal = $('#slider-bottom').data('slider').getValue();
var textval = parseInt(newVal);
if( textval >= 600 && textval < 6000){
finalvalue= 0.075;
finalbitvalue = textval * finalvalue;
}else if(textval >=6000 && textval < 30000 ){
finalvalue= 0.070;
finalbitvalue = textval * finalvalue;
}else if(textval >= 30000 ){
finalvalue= 0.065;
finalbitvalue = textval * finalvalue;
}
finalbtvalue = finalbitvalue/finalbtprice;
if(finalbtvalue){
$("#getdobtcval").html("<strong>"+finalbtvalue.toFixed(8)+"</strong>");
}
});
$('#slider-bottom').sliderTextInput();
});
</script>
$sql = "INSERT INTO buy_rate(hrate,hrate_price,in_username)
VALUES('".$h_rate."','".$hrate_price."','".$in_username."')";