Insert form to database

0

I have no experience in design, but I have this little problem I am putting a bad data, please help.

This is the form or just part of the error

<div class="col-md-6 col-sm-6 col-xs-12 xdisplay_inputx form-group has-feedback">
<input type="text" class="form-control has-feedback-left" name="jFecha" id="single_cal4" placeholder="Fecha Nacimiento" aria-describedby="inputSuccess2Status4">
<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
<span id="inputSuccess2Status4" class="sr-only">(success)</span>
  </div>

This is the js

$("#jugador-add").click(function () {
        $("#myModalj").modal();





         $("#aceptar_jugador").unbind('click');
                $("#aceptar_jugador").click(function () {


        var jNombre = document.getElementById("jNombre").value;
        var jApellido = document.getElementById("jApellido").value;
        var single_cal4 = document.getElementById("single_cal4").value;
        var jCedula = document.getElementById("jCedula").value;
        var jDireccion = document.getElementById("jDireccion").value;
        var jCiudad = document.getElementById("jCiudad").value;
        var jTelefono = document.getElementById("jTelefono").value;
        var jEstatura = document.getElementById("jEstatura").value;
        var jNumero = document.getElementById("jNumero").value;

        var jEmail = document.getElementById("jEmail").value;
        var jContraseña = document.getElementById("jContraseña").value;

        if ( jNombre == "" || jApellido == "" || single_cal4 == "" || jCedula =="" || jDireccion =="" || jCiudad =="" || jTelefono =="" || jEstatura =="" || jNumero =="" || jEmail =="" || jContraseña =="") {
                alert("Error: Todos los campos son obligatorios.");

            } else {
             $("#myModalj").modal('toggle');


        var params = {jNombre, jApellido, single_cal4, jCedula, jDireccion, jCiudad, jTelefono, jEstatura, jNumero, jEmail, jContraseña}

         $.ajax({
                type: 'POST',
                url: 'jugador-insert.php',
                data: params,
                async:true,

                    success: function(respuesta) {

                        alert("Informacion: Jugador creado correctamente!");
                        location.reload();
                             }

            });
            }
            });
        });

and this is the insert:

<?php

    $jNombre = $_POST['jNombre'];
    $jApellido = $_POST['jApellido'];
    $single_cal4 = $_POST['jFecha'];
    $jCedula = $_POST['jCedula'];
    $jDireccion = $_POST['jDireccion'];
    $jCiudad = $_POST['jCiudad'];
    $jTelefono = $_POST['jTelefono'];
    $jEstatura =$_POST['jEstatura'];
    $jNumero = $_POST['jNumero'];
    $jrefEquipo = $_POST['jrefEquipo'];
    $jrefPosicion = $_POST['jrefPosicion'];
    $jEmail = $_POST['jEmail'];
    $jContraseña = md5($_POST["jContraseña"]);

    $jregistro=date('Y-m-d');




    $sql="INSERT into tbljugadores (jNombre, jApellido, jFecha,  jCedula, jDireccion, jCiudad, jTelefono, jEstatura, jNumero, jrefEquipo, jrefPosicion, jEmail, jContraseña, jregistro)
            values ('$jNombre','$jApellido','$single_cal4','$jCedula','$jDireccion','$jCiudad','$jTelefono','$jEstatura','$jNumero','$jrefEquipo','$jrefPosicion','$jEmail','$jContraseña','$jregistro')";
    echo mysqli_query($con,$sql);
 ?>

The question is

Why does not save the date in the database all the fields are saved minus the date?

the field bd jFecha is type date and the html sends the data month day year

    
asked by useruuuu 19.07.2018 в 20:34
source

1 answer

0

Regarding your problem, sometimes it does not enter because the column created in the database is in DATE format and you do not insert the correct data.

The quickest and easiest solution would be to change that date column of the DB to a text type field by editing that column.

    
answered by 19.07.2018 в 20:56