2019-09-26 23:40:22 +02:00
|
|
|
<?php
|
2019-11-21 12:57:32 +01:00
|
|
|
include '../../config/config.php';
|
2019-09-26 23:40:22 +02:00
|
|
|
|
|
|
|
if($_POST['id'] !== null)
|
|
|
|
{
|
|
|
|
// Connexion à la base de données
|
2019-11-20 21:59:17 +01:00
|
|
|
$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
|
2019-09-26 23:40:22 +02:00
|
|
|
|
|
|
|
$params['product_id'] = $_POST['id'];
|
2019-10-14 00:56:07 +02:00
|
|
|
$filename = $_POST['nom_image'];
|
2019-10-15 00:09:23 +02:00
|
|
|
$nom_antenne = $_POST['antenne_slug'];
|
2019-09-26 23:40:22 +02:00
|
|
|
// Suppression du bien/service
|
|
|
|
$requete = "DELETE FROM products WHERE id = :product_id";
|
|
|
|
$stmt = $bdd->prepare($requete);
|
|
|
|
$stmt->execute($params);
|
2019-10-14 00:56:07 +02:00
|
|
|
// Suppression de la photo du produit si elle existe
|
2019-10-15 00:09:23 +02:00
|
|
|
$nom_fichier = '../uploads/products/'.$nom_antenne.'/'.$filename;
|
|
|
|
if (file_exists($nom_fichier)) {
|
|
|
|
unlink($nom_fichier);
|
2019-10-14 00:56:07 +02:00
|
|
|
}
|
2019-09-26 23:40:22 +02:00
|
|
|
}
|
|
|
|
|