I want to delete a row from my table and I want to do it by means of a form
in which I say the id of that row.
Why do you tell me that I have not defined the value? I mean, is not it picked up like this?
$valor = mysqli_real_escape_string($conexion, $_POST['idEliminar']);
Error
Notice: Undefined index: id Delete in C: \ xampp \ htdocs \ PHP_WEB_MMR \ P3 \ PHP \ delete.php on line 12
Code
<form action="PHP/eliminar.php">
<input type="text" name="idEliminar" placeholder="ID del usuario a eliminar" required>
<input type="submit" value="Eliminar">
</form>
<?PHP
// Conectamos con la base de datos LOCAL
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "carrot";
$conexion = mysqli_connect($bd_host, $bd_usuario, $bd_password, $bd_base);
// Recojo los datos del formulario - NOTAR EL USO DE LA FUNCIÓN DE ESCAPADO
$valor = mysqli_real_escape_string($conexion, $_POST['idEliminar']);
// Hacemos la consulta. En este caso queremos eliminar el usuario registrado
$consulta = "DELETE FROM usuarios_pass WHERE id = $valor";
$resultado = mysqli_query($conexion, $consulta);
// Liberamos y cerramos conexión.
//mysqli_free_result($resultado);
//mysqli_close($conexion);
?>
As you can see, I had to comment
mysqli_free_result($resultado);
because as always I get an error, which as much as I read and explain to me I do not understand.
I know it must be very basic but the truth is that the PHP + SQL theme is making me a world.
Health!