< a href="https://i.stack.imgur.com/7ngv4.png"> I have an update system of data for a web page of news, consists of a form to put image, title, subtitle, text .. The form serves, works correctly, I know because when I use it, the rows of my database are updated and also I put an alert that indicates that the database was updated by doing SUBMIT, but suddenly the table goes crazy, and it is not updated, the row remains empty.
It must be said that all fields are with VARCHAR (1000) and the field TEXT and TEXT2 are with LongText.
the code would be the following:
<?php
//Declaracion de variables
$etiqueta = $_POST["etiqueta"];
$autor = $_POST["autor"];
$fecha = $_POST["fecha"];
$titulo = $_POST["titulo"];
$subtitulo = $_POST["subtitulo"];
$texto = $_POST["texto"];
$texto2 = $_POST["texto2"];
$imagenCortesia = $_POST["cortesia"];
$imagen_nombre = $_FILES['imagen']['name'];
$imagen_archivo = $_FILES['imagen']['tmp_name'];
$ruta = "imagenesNoticias";
$ruta = $ruta."/".$imagen_nombre;
//Crear Variables para conexion Noticias Principales
$host = "localhost";
$user = "********";
$pw = "*************";
$dataBase1 = "kautivai_DatosDeNoticias";
//========================= Consulta ============================//
//Consulta de campos llenos
if(isset($_POST['etiqueta']) && !empty($_POST['etiqueta']) &&
isset($_POST['autor']) && !empty($_POST['autor']) &&
isset($_POST['fecha']) && !empty($_POST['fecha']) &&
isset($_POST['titulo']) && !empty($_POST['titulo']) &&
isset($_POST['subtitulo']) && !empty($_POST['subtitulo']) &&
isset($_POST['texto']) && !empty($_POST['texto']) &&
isset($_POST['texto2']) && !empty($_POST['texto2']) &&
isset($_POST['cortesia']) && !empty($_POST['cortesia']) &&
isset($_FILES['imagen']['tmp_name']) && !empty($_FILES['imagen']['tmp_name'])){
$conexion = mysqli_connect($host, $user, $pw) or die("Problemas al conectar con base de datos 'kautivai_DatosDeNoticias'");
mysqli_select_db($conexion, $dataBase1) or die("Problemas al conectar con base de datos 'kautivai_DatosDeNoticias'");
move_uploaded_file($imagen_archivo, $ruta);
//Toma de datos y paso a base de datos
mysqli_query($conexion, "INSERT INTO Noticia1(Etiqueta, Autor, Fecha, Titulo, Subtitulo, Texto, Texto2, Cortesia, RutaImagen) VALUES('$etiqueta', '$autor', '$fecha', '$titulo', '$subtitulo', '$texto', '$texto2', '$imagenCortesia', '$ruta')");
echo "<script>
alert('Los Datos han sido guardados, Base de datos actualizada!');
window.history.go(-1);
</script>";
} else {
echo "Problemas al insertar los Datos en la base de datos 'kautivai_DatosDeNoticias'";
}
mysqli_close($conexion);
?>
Does anyone have any idea what is happening?