To be honest I have not studied crud, I made the create easily but I have a problem to make an edit. I did a get to receive a value auto increment (id) to load the fields that have that id, the problem is that when I give submit the variable id is empty because it sends me to the root of the file without the id and not I can change the values because the id disappears. Could you help me with this problem? Should I try otherwise (since in my view it only works to load fields from that id) or can I do it? Thanks in advance. Silvers.
<?php
$conexion = mysqli_connect("localhost","root","","somber_destiny") or die();
$ID = isset($_GET['id']) ? (int)$_GET['id'] : header('location: administrar.php');
if (isset($_GET['id'])) {
$consulta = mysqli_query($conexion,"SELECT SQL_CALC_FOUND_ROWS * FROM articulos WHERE ID = $ID");
echo "Si existe la id $ID";
}
if (isset($_POST['submit'])) {
$consulta = mysqli_query($conexion,"SELECT SQL_CALC_FOUND_ROWS * FROM
articulos WHERE ID = $ID");
$ID = $_POST['id'];
$titulo = $_POST['titulo'];
$tipo = $_POST['tipo'];
$legenda = $_POST['legenda'];
$texto = $_POST['texto'];
$imagen = $_POST['imagen'];
$actualizar = mysqli_query($conexion,"UPDATE articulos SET titulo =
'$titulo', tipo = '$tipo', legenda = '$legenda', texto = '$texto', imagen
= $imagen WHERE ID = $ID");
header("location: editar.php?id=3");
}
require 'views/editar.view.php'
?>