Date can not enter the bbdd

1

Problem: The date of birth, does not enter the bbdd. I cut out as much as possible both the code and the form and the answer it gives me when I want to enter. The reality is that there are 25 fields. And several are date, several are select, others are combobox, and it always stops on the first date it finds. The strangest thing is that I made a page for each type and its respective base of 6 fields, and all, even the date enter without problems.

    <?php
if(isset($_POST['bt-021']))
{
    include("99_conn.php");
if($conexion === false){
    die("ERROR: No pudo conectarse. " . mysqli_connect_error());
}
$ap=$POST['ap'];
$nom=$POST['nom'];
$fen=$POST ['fen'];
$nac=$POST['nac'];
$userac= $_SESSION["98_idusr"];

$sql021 = ("INSERT INTO z_dato_pac (00_apellido, 00_nombres, 00_fenacim, 00_nacional) VALUES ('$ap', '$nom', '$fen', '$nac')");
if(mysqli_query($conexion, $sql021))
{
echo "OK $error $sql021 $ap, $nom, $fen, $nac, $userac";
}else
{
echo "ERROR: $error $sql021 $ap, $nom, $fen, $nac, $userac" . mysqli_error($conexion);
}
?>

ERROR RESPONSE ERROR: INSERT INTO z_dato_pac (00_surname, 00_names, 00_fenacim, 00_national) VALUES ('', '', '', '', '20'), 20Incorrect date value: '' for column '00_fenacim' at row 1

Del formulario HTML

    <td><input name="nom" type="text" id="nom" form="f021" placeholder="Nombres" title="nom" size="20" maxlength="30"></td>
    <td><input name="ap" type="text" id="nom" form="f021" placeholder="Apellidos" title="ap" size="20" maxlength="30"></td>
    <td>Fe.nac. <input name="fen" type="date" id="fen" form="f021" title="fen"></td>
    <td><input name="nac" type="text" id="nac" form="f021" placeholder="Nacionalidad" title="nac" size="20" maxlength="20"></td>
</tr>

HEAD AND FOOT OF THE FORM

<form method="post" id="f021" title="f021">
    <table width="700" border="0" cellspacing="0" cellpadding="0">
    <tbody>
        <tr>
            <td><input name="nom" type="text" id="nom" form="f021" placeholder="Nombres" title="nom" size="20" maxlength="30"></td>
            <td><input name="ap" type="text" id="nom" form="f021" placeholder="Apellidos" title="ap" size="20" maxlength="30"></td>
            <td>Fe.nac. <input name="fen" type="date" id="fen" form="f021" title="fen"></td>
            <td><input name="nac" type="text" id="nac" form="f021" placeholder="Nacionalidad" title="nac" size="20" maxlength="20"></td>
        </tr>
        <tr>
            <td colspan="4"><input name="bt-021" type="submit" class="button" id="bt-021" form="f021" formmethod="POST" title="bt_021" value="Registrar"></td>
        </tr>
    </tbody>
</table>
        </form>
    
asked by Silvia Gaviota Garcia 29.09.2017 в 23:29
source

1 answer

0

I already found your problem is here,

$ap=$POST['ap'];
$nom=$POST['nom'];
$fen=$POST ['fen'];
$nac=$POST['nac'];
$userac= $_SESSION["98_idusr"];

should be like this, the global $ _POST is underscored:

$ap=$_POST['ap'];
    $nom=$_POST['nom'];
    $fen=$_POST ['fen'];
    $nac=$_POST['nac'];
    
answered by 30.09.2017 / 00:15
source