ajax - select query not working php -
i make ajax page php script , computations on result obtained there , return values.
<form id="couponform"> apply coupon: <input type="text" name="addcode" placeholder="apply coupon"> <input class="button" style="margin-left:10px;" type="submit" value="apply"> </form> <script> $('#couponform').on('submit',function(e){ e.preventdefault(); var formdata=$(this).serialize(); var totalprice=<?php if(isset($total))echo $total;else echo'"'.'"';?>; formdata=formdata+'&totalprice='+totalprice; $.ajax({ url:'/cart/couponajax.php', type:'post', datatype:'json', data:formdata, success: function (content) { //something } }); }) </script>
the above page calls php script looks
require 'config.php';// contains db credentials $totalprice=$_post['totalprice']; $couponname=mysqli_real_escape_string($mysqli,$_post['addcode']); $state=$mysqli->prepare('select * `coupons` `name`=?'); $state->bind_param('s',$couponname); $state->execute(); $result=$state->get_result(); // $result returns null.
when check value obtained in $result
, shows me this
db looks this
i stuck in thing hours , doing wrong here ?
update:
Comments
Post a Comment