<?php

require_once '../../../Entity/connexion_db.php';
require_once '../../../Entity/destination.php';
session_start();
$bdd = connexion_db::getInstance();
if ($_SESSION['admin'] == true && isset($_GET["destination_id"])) {
    //echo 'OK';
    $modif = $bdd->query("SELECT * FROM destination WHERE id_dest =" . $_GET["destination_id"] . ";");
    $dest = $modif->fetch();
    if (isset($_POST['destination']) && isset($_POST['destination_descr']) && isset($_POST['image'])) {
        try {
            $destination = new destination(addslashes($_POST['destination']), $_POST['image'], addslashes($_POST['destination_descr']));
            $destination->updateDestination($destination->getNom(), $destination->getPhoto(), $destination->getDescription(), $_GET["destination_id"]);
            header("location:destination-liste.php");
        } catch (Exception $ex) {
            echo 'erreur lors de l\\a modification de la destination' . $ex->getMessage();
        }
    }
} else {
    header('location: ../../index.php');
}
?>

<html lang="en">
<head>
    <link rel="stylesheet" type="text/css" href="../../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../../../css/style.css">
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<?php

require_once '../../../Entity/connexion_db.php';
require_once '../../../Entity/destination.php';
session_start();
if ($_SESSION['admin'] == true) {
    //echo 'OK';
    if (isset($_POST['destination']) && isset($_POST['destination_descr']) && isset($_POST['image'])) {
        try {
            $destination = new destination(addslashes($_POST['destination']), $_POST['image'], addslashes($_POST['destination_descr']));
            $destination->addDestination($destination->getNom(), $destination->getPhoto(), $destination->getDescription());
            header("location:destination-liste.php");
        } catch (Exception $ex) {
            echo 'erreur lors de l\'ajout de la destination' . $ex->getMessage();
        }
    }
} else {
    header('location: ../../index.php');
}
?>

<html lang="en">
<head>
    <link rel="stylesheet" type="text/css" href="../../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../../../css/style.css">
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<?php 
include '../navbar.html';
?>