I am learning to connect MySQLi PHP
with MySQL, I made this CRUD but it does not work correctly. Only works in table Alumno
, but not in table Matricula
.
I already tried with mysqli_multi_query()
and with different ways to make it work and I do not find how.
include 'Conexion.php';
if(isset($_POST['Registrar']))
{
$IDalumn = "";
$nomalumn ="";
$apealumn ="";
$IDalumn = $_POST['IdAlu'];
$nomalumn = $_POST['NomA'];
$apealumn = $_POST['ApeA'];
$IDgrado = $_POST["IDgrado"];
$fechaingre = $_POST["FechaIngre"];
$query1 = "INSERT INTO matricula(IDalumno,IDgrado,FechaIngreso)VALUES
('$IDalumn','$IDgrado','$fechaingre')";
$query2 = "INSERT INTO alumno(IDalumno,Nombres,Apellidos)VALUES
('$IDalumn','$nomalumn','$apealumn')";
$Create = mysqli_query($conexion,$query1);
$Create1 = mysqli_query($conexion,$query2);
mysqli_close($conexion);
}
Here is the HTML code
<table>
<ul>
<li>
<input name="IdAlu" id="IdAlu" type="text" maxlength="5">
Digite la identificacion del alumno:
</li>
<li>
<input name="NomA" id="NomA" type="text" maxlength="40">
Digite Los nombres del alumno:
</li>
<li>
<input name="ApeA" id="ApeA" type="text" maxlength="40">
Digite Los apellidos del alumno:
</li>
<li>
<input name="IDgrado" id="IDgrado" type="text"
maxlength="2" > Digite la identificacion de grado al que ingresa el
alumno:
</li>
<li>
<input name="FechaIngre" id="FechaIngre" type="date">
Digite la fecha en la que ingresa el alumno:
</li>
<input type="submit" name="Registrar" value="AGREGAR"/>
<input type="submit" name="Actualizar" Value="ACTUALIZAR">
</ul>
</table>