I have a form, they are around 50 fields, but the point is that sometimes the user will only fill 10 or 20 fields, they are not always 50,
then I had the required in my forms and I removed it, so that it was no longer mandatory to complete all the fields, and in the bd all the fields are in Null,
but when filling in 5 fields, do not insert them, I do not know how to do so that at least if they are empty I insert a 0 as default. He inserts them only when all the fields are completed.
One field of the form (the other fields are like that only the names change) HTML:
<input type="text" name="txtm9a1" id="txtm9a1" value="<?php echo $_POST['txtm9a1'];?>">
Insertion by PHP fix:
$insertar_de[44]=$_POST['txtm9a1'];
Structure of the table, they are 50 fields but all are equal to this, of course you have your primary key.
The solution you made to insert an empty field was to validate the post
if (empty($_POST['txtm9a1'])) { //Si esta vacio el campo
$insertar_de[44] = 0; //en mi caso inserta 0, pero puede ser null tambien.
} else if (!empty($_POST['txtm9a1'])) { // Y si esta lleno el campo manda lo que se lleno en la caja de texto
$insertar_de[44] = $_POST['txtamp1']; //Insertar lo que tiene la caja txt.