-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
35 lines (31 loc) · 864 Bytes
/
Copy pathdelete.php
File metadata and controls
35 lines (31 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
include("templates/header.php");
$dsn = 'mysql:host=localhost;dbname=Bienchezsoi';
$db = new PDO($dsn, "root", "root");
if (isset($_GET['id']) && isset($_GET['categorie'])) {
$id = $_GET['id'];
$categorie = $_GET['categorie'];
switch ($categorie) {
case 'chaises':
$sql = "DELETE FROM chaises WHERE id = :id";
break;
case 'bureau':
$sql = "DELETE FROM bureau WHERE id = :id";
break;
case 'tables':
$sql = "DELETE FROM tables WHERE id = :id";
break;
default:
echo "Catégorie non reconnue.";
exit;
}
$query = $db->prepare($sql);
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute();
header('Location: index.php');
exit;
} else {
echo "Paramètres manquants.";
exit;
}
?>