I make a module in which I intend to update my records, validating that the non_active field is filled in my form. But I get an error that the active number field is empty, but in my form it is full.
I already checked my code but I can not find the error.
I hope you can help me. Greetings.
<?php
session_start();
if (empty($_POST['no_activo'])) {
$errors[] = "Campo número de activo vacio";
} else if (
!empty($_POST['no_activo'])
){
include "../config/config.php";//Contiene funcion que conecta a la base de datos
$no_activo = $_POST["no_activo"];
$fecha = $_POST["fecha"];
$concepto = $_POST["concepto"];
$factura = $_POST["factura"];
$pedimento = $_POST["pedimento"];
$importe = $_POST["importe"];
$ubicacion_id = $_POST["ubicacion_id"];
$estado_id = $_POST["estado_id"];
$area_id = $_POST["area_id"];
$estado_id = $_POST["estado_id"];
$final_id = $_POST["final_id"];
$area_id = $_POST["area_id"];
$ubicacion_id = $_POST["ubicacion_id"];
$empresa_id = $_POST["empresa_id"];
$etiqueta = $_POST["etiqueta"];
$id=$_POST['id'];
$sql = "update oficina set no_activo=\"$no_activo\",fecha=\"$fecha\",concepto=\"$concepto\", factura=\"$factura\",pedimento=\"$pedimento\",importe=\"$importe\",ubicacion_id=\"$ubicacion_id\",estado_id=\"$estado_id\", area_id=\"$area_id\" where id=$id";
$query_update = mysqli_query($con,$sql);
if ($query_update){
$messages[] = "El equipo ha sido actualizado satisfactoriamente.";
} else{
$errors []= "Lo siento algo ha salido mal intenta nuevamente.".mysqli_error($con);
}
} else {
$errors []= "Error desconocido.";
}
if (isset($errors)){
?>
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Error!</strong>
<?php
foreach ($errors as $error) {
echo $error;
}
?>
</div>
<?php
}
if (isset($messages)){
?>
<div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>¡Bien hecho!</strong>
<?php
foreach ($messages as $message) {
echo $message;
}
?>
</div>
<?php
}
?>