I have the following problem:
I am trying to send data from a form and the problem arises when I make a decision and try to update
Code:
<?php
include "plantillas/conexion.php";
$clave = $_POST["clave"];
$centro = $_POST["centro"];
$site = $_POST["site"];
$destino = $_POST["destino"];
$marca = $_POST["marca"];
$conector = $_POST["conector"];
$puerto = $_POST["puerto"];
$consulta_site = mysqli_query($con, "SELECT * FROM site WHERE centro = '".$centro."' AND nombre = '".$site."'")or die("Error: ". mysqli_error($con));
while ( $row_site = mysqli_fetch_array($consulta_site)) {
$id = $row_site["id"];
}
if ($id != "") {
$update = mysqli_query ($con,"UPDATE site
SET odf = '$clave'
WHERE id = '$id'") or die("fallo al actualizar los datos: ".mysqli_error($con));
if ($update) {
$insertar = mysqli_query ($con,"INSERT INTO odf VALUES (NULL,'$clave','$centro', '$site', '$marca', '$conector', '$puerto', '$destino')");
header('Location: sistema.php');
}else{
echo "Error al Insertar los datos";
}
} else{
echo "El centro de trabajo no esta registrado";
}
?>
and the error that marks me is:
Notice: Undefined variable: id in F: \ xampp \ htdocs \ CFE \ odf_site.php on line 17
I hope and you can help me!