PHP/blibliotheque
2025-05-13 13:31:26 +00:00

22 lines
537 B
Plaintext

<?php
$pdo = new PDO("mysql:host=localhost;dbname=MaBibliotheque", "root", "");
if ($_POST && $_POST['titre'] && $_POST['auteur']) {
$pdo->prepare("INSERT INTO livres (titre, auteur) VALUES (?, ?)")
->execute([$_POST['titre'], $_POST['auteur']]);
header("Location: index.php");
exit;
}
?>
<form method="post">
<input name="titre" placeholder="Titre" required><br><br>
<input name="auteur" placeholder="Auteur" required><br><br>
<button>Ajouter</button>
</form>
<p><a href="index.php">Retour</a></p>