php - Form Data Not posting to database -
can see wrong below code. when submit data using html form expected confirmation confirm registered. however, when check database not there!
i have checked names same names of each input correct , can confirm database connected successfully, along names of database columns ect...
any appreciated.
<?php if (isset($_post['carrierinsert'])) { $acc = $_post['acc']; $sql = "select cariers.acc cariers cariers.acc ='$acc'"; $result = $db->query($sql); if($result->num_rows > 0) { echo "<font color='red'>carrier exits</font>"; $sql = "insert cariers ( `reg`, `acc`, `accstatus`, `carramid`, `carrfloor`, `pay`, `comms`) values ( '".$db->real_escape_string($_post['reg'])."', '".$db->real_escape_string($_post['acc'])."', '".$db->real_escape_string($_post['accstatus'])."', '".$db->real_escape_string($_post['carramid'])."', '".$db->real_escape_string($_post['carrfloor'])."', '".$db->real_escape_string($_post['pay'])."', '".$db->real_escape_string($_post['comms'])."' )"; $insert = $db->query($sql); echo "<font color='red'>carrier inserted</font>"; } } ?> <h1>add new</h1> <hr> <form method="post" action=""> carrier<br /> <input name="reg" type="text" required="required" value=""> <br /><br /> number<br /> <input name="acc" type="text" required="required" value=""> <br /><br /> status<br /> <input name="accstatus" type="text" required="required" value=""> floor<br /> <select name="carrfloor" id="carrfloor"> <option name="carrfloor" value="1">1</option> <option name="carrfloor" value="2">2</option> </select> <br /><br /> pay<br /> <select name="pay" id="pay"> <option selected="selected" name="pay" value="0">n/a</option> <option name="pay" value="1">1%</option> <option name="pay" value="1.25">1.25%</option> <option name="pay" value="1.5">1.5%</option> <option name="pay" value="1.75">1.75%</option> <option name="pay" value="2">2%</option> <option name="pay" value="2.25">2.25%</option> <option name="pay" value="2.50">2.50%</option> <option name="pay" value="3.00">3%</option> </select> <br /><br /> additional charge<br /> <select name="comms" id="comms"> <option name="comms" selected ="selected" value="fees">yes</option> <option name="comms" value="no fees">no</option> </select> <br /><br /> manager<br /> <select name="carramid" id="carramid"> <option name="carramid" value="yes">yes</option> <option name="carramid" value="no">no</option> </select> <br /><br /> <br /><br /> <input type="submit" class="btn" name="carrierinsert" value="save" /> </form>
$sql = "insert cariers ( reg, acc, accstatus, carramid, carrfloor, pay, comms) values ( '".{$db->real_escape_string($_post['reg'])}."', '".{$db->real_escape_string($_post['acc'])}."', '".{$db->real_escape_string($_post['accstatus'])}."', '".{$db->real_escape_string($_post['carramid'])}."', '".{$db->real_escape_string($_post['carrfloor'])}."', '".{$db->real_escape_string($_post['pay'])}."', '".{$db->real_escape_string($_post['comms'])}."' )";
update
$a = 15; echo 'this not write 15: $a' .php_eol. "this write 15: $a" .php_eol. "but can escape variable anyways. dont need change quotes".$a.' dot (.) add method strings' ;
Comments
Post a Comment