Hi, need new eyes on this. I fill in form to insert, it does insert but not what I entered ------------------------------------------------------------ this is the form code- truncated <!DOCTYPE html><html> <head> </head> <body><center><b> <FORM action=maintinsert.php method=post> Id<INPUT TYPE="text" size=5 name=id> Unit<INPUT TYPE="text" size=5 name=unit> Tenant<INPUT TYPE="text" size=25 name=tenant> Date<INPUT TYPE="text" size=10 name=datereceived> Time<INPUT TYPE="text" size=7 name=time> Work Area = <select name="area"> <option value="kitchen" selected>kitchen</option> <option value="bath">bath</option> </select> Problem = <select name="problem"> <option value="blinds" selected>blinds</option> <option value="bifolds">bifolds</option> </select> Action Taken = <select name="action"> <option value="repaired" selected>repaired</option> <option value="replaced">replaced</option> </select> <p> Date Completed - <font color=red>Day then mm/yyyy</font> compday<INPUT TYPE="text" size=2 name=compday> compmoyr<INPUT TYPE="text" size=7 name=compmoyr> cost<INPUT TYPE="text" size=10 name=cost> charge<INPUT TYPE="text" size=10 name=charge> ordno - if insp<INPUT TYPE="text" size=10 name=ordno><p> <INPUT type="submit" value="submit data" /> </p> </form> </center></b></body></html> PHP: --------------------------------------------------------------- this is program code <?php echo "<center>";echo date('m/d/y');echo "</center>"; //Open a new connection to the MySQL server require_once "getprerentdb.php"; $id = "id"; $unit = "unit"; $tenant = "tenant"; $datereceived = "datereceived"; $time = "time"; $area = "area"; $problem = "problem"; $action = "action"; $compday = "compday"; $compmoyr = "compmoyr"; $cost = "cost"; $charge = "charge"; $ordno = "ordno"; //MySqli Insert Query $sql="INSERT INTO maintdata (id,unit,tenant,datereceived,time,area,problem,action,compday,compmoyr,cost,charge,ordno) VALUES('$id','$unit','$tenant','$datereceived','$time','$area','$problem','$action','$compday','$compmoyr', '$cost','$charge','$ordno')"; if (!$mysqli -> query($sql)) { printf("%d Row inserted.\n", $mysqli->affected_rows); } echo "unit $unit data inserted</font><br /><br />"; $mysqli -> close(); ?> PHP: ---------------------------------------------------------------- this is message 03/17/21 unit unit data inserted --------------------------------------------------------------------------------------------------------- this is the table before execution id unit tenant datereceived time area problem action compday compmoyr ordno cost charge 1 apt1 tenant1 12/26/2020 5:45pm kitchen leak in jutchen replaced seal in drain 26 12/2020 257 0.33 0.00 2 apt2 tenant2 12/27/2020 9:55am bathroom noisy fan replaced fan 27 12/2020 258 34.25 0.00 3 dpt3 tenant3 12/28/2020 10:20am living room sparks fly from tv replaced receptacle and end on tv chord 28 12/2020 259 2.57 0.63 4 apt4 tenant5 12/28/2020 11:10am outside back door light burned out replaced bulb 28 12/2020 259 0.75 0.00 5 apt5 tenant5 12/30/2020 8:25am kitchen fridge not getting cold replaced door seal 30 12/2020 260 12.68 0.00 ---------------------------------------------------------------------------------------------------------------------- this is the table after execution. Note inserted entry "id 44".should be "6" id unit tenant datereceived time area problem action compday compmoyr ordno cost charge 1 apt1 tenant1 12/26/2020 5:45pm kitchen leak in jutchen replaced seal in drain 26 12/2020 257 0.33 0.00 2 apt2 tenant2 12/27/2020 9:55am bathroom noisy fan replaced fan 27 12/2020 258 34.25 0.00 3 dpt3 tenant3 12/28/2020 10:20am living room sparks fly from tv replaced receptacle and end on tv chord 28 12/2020 259 2.57 0.63 4 apt4 tenant5 12/28/2020 11:10am outside back door light burned out replaced bulb 28 12/2020 259 0.75 0.00 5 apt5 tenant5 12/30/2020 8:25am kitchen fridge not getting cold replaced door seal 30 12/2020 260 12.68 0.00 44 unit tenant datereceiv time area problem action co compmoy ordno 0.00 0.00
assuming that the id field is autoincrement I'd change your insert to this and let the database decide what the id should be. $sql="INSERT INTO maintdata (unit,tenant,datereceived,time,area,problem,action,compday,compmoyr,cost,charge,ordno) VALUES('$unit','$tenant','$datereceived','$time','$area','$problem','$action','$compday','$compmoyr', '$cost','$charge','$ordno')"; PHP: