I have a db and the table I have it in phpmyadmin does not insert data

0

CONNECTION.PHP

<?php 
    $conexion = new mysqli("localhost", "fran","123","frankliber");
 ?>

FORMULARIO.PHP

<!DOCTYPE html>-
<html>
<head>
    <title>Guardar</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="formulario.css">

</head>
<body>
    <center>
        <form action="operacio_guardar.php" method="POST"><br/><br/><br/>
            <input type="text" REQUIRED name="matricula" placeholder="Número de matricula" value=""><br><br>
                <input type="text" REQUIRED name="nombre" placeholder="Nombre completo" value=""><br><br>
                <input type="text" REQUIRED name="periodo" placeholder="Periodo actual" value=""><br><br>
                <input type="text" REQUIRED name="biologia" placeholder="Nota biologia" value=""><br><br>
                <input type="text" REQUIRED name="sociales" placeholder="Nota sociales" value=""><br><br>
                <input type="text" REQUIRED name="etica" placeholder="Nota etica" value=""><br><br>
                <input type="text" REQUIRED name="artistica" placeholder="Nota artistica" value=""><br><br>
                <input type="text" REQUIRED name="edufisica" placeholder="Nota edu.fisica" value=""><br><br>
                <input type="text" REQUIRED name="religion" placeholder="Nota religión" value=""><br><br>
                <input type="text" REQUIRED name="castellano" placeholder="Nota castellano" value=""><br><br>
                <input type="text" REQUIRED name="matematicas" placeholder="Nota matematicas" value=""><br><br>
                <input type="text" REQUIRED name="tecnologia" placeholder="Nota tecnologia" value=""><br><br>
                <input type="text" REQUIRED name="ccpv" placeholder="Nota ccpv" value=""><br><br>
                <input type="text" REQUIRED name="fisica" placeholder="Nota física" value=""><br><br>
                <input type="text" REQUIRED name="quimica" placeholder="Nota quimica" value=""><br><br>
                <input type="text" REQUIRED name="observaciones" placeholder="observaciones" value="">

            <input class="boton" type="submit" value="Aceptar">
        </form>
    </center>
</body>
</html>

FORMULARIO.CSS

body{
    background-image: url("https://4.bp.blogspot.com/-3hDCx5wKrDA/UZATKWgw-UI/AAAAAAAACmo/Mwgj_sTrffk/s1600/Descargar+Pack+Fondos+de+escritorio+Animacion+HD+(306).jpg");
    background-repeat: no-repeat;
    width: auto;
    height: auto;
}
.caja{
    width: 300px;
    height: 30px;
    border-radius: 10px;

}
.boton{
    width: 80px;
    height: 30px;
    color: white;
    background-color: black;
    cursor: pointer;
    border-radius: 10px;
    border:none;
}
.boton:hover{
    width: 100px;
    height: 40px;
    color: white;
    background-color: red;
    cursor: pointer;
    border:none;
}
table{
    width: 600px;
    height: auto;
    background-color: white;


}
#campos{
}

OPERATION_GUARDAR.PHP

<?php 
    include("conexion.php");

        $matricula=$_POST['matricula'];
        $nombre=$_POST['nombre'];
        $periodo=$_POST['periodo'];
        $biologia=$_POST['biologia'];
        $sociales=$_POST['sociales'];
        $etica=$_POST['etica'];
        $artistica=$_POST['artistica'];
        $edufisica=$_POST['edufisica'];
        $religion=$_POST['religion'];
        $castellano=$_POST['castellano'];
        $matematicas=$_POST['matematicas'];
        $tecnologia=$_POST['tecnologia'];
        $ccpv=$_POST['ccpv'];
        $fisica=$_POST['fisica'];
        $quimica=$_POST['quimica'];
        $observaciones=$_POST['observaciones'];

        $query= "INSERT INTO estudiantes(matricula,nombre,periodo,biologia,sociales,etica,artistica,edufisica,religion,castellano,matematicas,tecnologia,ccpv,fisica,quimica,observaciones) VALUES('$matricula','$nombre','$periodo','$biologia','$sociales','$etica','$artistica','$edufisica','$religion'.'$castellano','$matematicas','$tecnologia','$ccpv','$fisica','$quimica','$observaciones')";

        $resultado = $conexion->query($query);

        if($resultado){
            echo "insercion existosa";
        }
        else{
            echo "insercion fallida";
        }
    
asked by FRANKLIBER GEORGE GUZMAN VILLA 18.07.2018 в 15:56
source

1 answer

0

--- In your file operacio_guardar.php you have a period (.) between the variables '$ religion'. '$ castellano' should be changed by a comma (,)

and finally for an error to be printed you could add the following below your $query = "INSERT INTO ... instruction:

if (mysqli_query($conexion, $query)) {
            echo "insercion existosa";
        } else {
            echo "insercion fallida: " . $query . "<br>" . mysqli_error($conexion);
        }   

With these changes you should be able to enter the data in your table, any comment you do know.

    
answered by 18.07.2018 в 16:54