Good I'm trying to delete data from php to mysql but I can not get it. It does not give any errors but it does not work.
here I show the data and create a button to delete the data
<?php
while($variable = $consulta->fetch_assoc())
{
?>
<tr>
<td><?php echo $variable['nombre']; ?></td>
<td><?php echo $variable['apellido']; ?></td>
<td><?php echo $variable['correo']; ?></td>
<td><?php echo $variable['contrasena']; ?></td>
<td>
<form method="post" action="acciones.php?accion=consultaeli&nombre=<?php echo $variable['nombre']; ?>">
<input name="btneliminar" type="button" value="Eliminar" type="submit" class="btn btn-danger" />
</form>
</td>
</tr>
<?php
}
?>
and here I have the php to delete
<?php
$conexion = new mysqli("localhost", "root", "", "bbdd");
if ($conexion->connect_errno) {
echo "Fallo al conectar a MySQL: (" . $conexion->connect_errno . ") " . $conexion->connect_error;
}
else{
$accion=$_POST["accion"];
switch($accion)
{
case "consultaeli":
$nombre=$_POST["nombre"];
header("Location: usuarios.php"); //pagina desde la que se hace la llamada
$borrar = "DELETE FROM usuarios where nombre='$nombre'"
mysqli_query($conexion, $borrar);
mysqli_close($conexion);
break;
}
}
?>