I am doing a CRUD and when I finish filling out the form it appears that the "patient has registered", that is what I should say if the records are sent correctly to the table. BUT when going to the table there is nothing (records do not appear) the code does not seem to have syntax errors according to the word processor. can you help me?
the codes are as follows:
/ conexion /
<?php
try {
$base=new PDO('mysql:host=localhost; dbname=bdnutriologo','root','');
$base->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$base->exec("SET CHARACTER SET UTF8");
}catch(Exception $e){
die ('error' .$e->getMessage());
echo "linea del error" .$e->getMessage();
}
?>
/ inserting records into the database using PDO /
<?php
include ("conexion.php");
$registros=$base->query("SELECT * FROM expediente")-
>fetchAll(PDO::FETCH_OBJ);
if(isset($_POST["cr"])){
$id_exp=$_POST["id_exp"];
$peso=$_POST["peso"];
$edad=$_POST["edad"];
$estatura=$_POST["estatura"];
$fecha_registro=$_POST["fecha_registro"];
$sexo=$_POST["sexo"];
$objetivo=$_POST["objetivo"];
$sql="INSERT INTO expediente (id_exp, peso, edad, estatura, fecha_registro, sexo, objetivo ) VALUES (:idx, :pes, :edd, :est, :fech, :sex, :obj)";
$resultado=$base->prepare($sql);
$resultado->execute(array(":idx"=>$id_exp, ":pes"=>$peso, ":edd"=>$edad, ":est"=>$estatura, ":fech"=>$fecha_registro, ":sex"=>$sexo, ":obj"=>$objeto));
}
echo "El paciente fue dado de alta.";
?>