On the page when the user gives you to save changes in the form:
echo"<form id='contact' action='actualizar.php' method='post' name='actualizar'>";
echo "<fieldset>";
echo " Nombre:<span class='obligatorio'>*</span>";
echo " <input placeholder='Nombre' type='text' tabindex='1' name='nombre' required autofocus value='$nombre'>";
echo "</fieldset>";
echo "<fieldset>";
echo " Dirección:<span class='obligatorio'>*</span>";
echo " <input placeholder='Dirección' type='text' tabindex='2' name='direccion' required value='$direccion'>";
echo "</fieldset>";
echo " <button name='submit' type='submit' id='contact-submit' data-submit='Enviando...'>Enviar</button>";
echo "</fieldset>";
And in my page to update I make the following SQL statement to update the data that the user has sent
<?php
$mysqli = new mysqli("localhost", "root", "", "Clientes");
$nombre = $_POST['nombre'];
$direccion = $_POST['direccion'];
$id = $_GET['idCliente'];
if ($stmt = $mysqli->prepare("UPDATE clientes SET Nombre = '$nombre', Direccion = '$direccion' WHERE idCliente = ?")) {
$stmt->bind_param("i", $id);
$stmt->execute();
if(!$stmt->execute()){
echo "Error actualizando al usuario";
}
else
echo "<a href='mostrar.php'>Datos guardados correctamente, Volver</a>";
$mysqli->close();
}
?>
I just run it but it shows the link to go back but it does not update the data