BRE03

Exercice Pratique PDO - Correction de l’étape 8

delete-address.html

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Delete address</title>
</head>
<body>
<form action="delete-address.php" method="post">
    <fieldset>
        <label for="id">
            Id
        </label>
        <input type="text" name="id" id="id" />
    </fieldset>
    <fieldset>
        <button type="submit">Envoyer</button>
    </fieldset>
</form>
</body>
</html>

delete-address.php

require "connexion.php";

$id = $_POST['id'];

$query = $db->prepare("DELETE FROM address WHERE id = :id");
$parameters = [
    'id' => $id
];
$query->execute($parameters);