<?php

require_once '../../../Entity/connexion_db.php';
require_once '../../../Entity/aeroport.php';
session_start();
$bdd = connexion_db::getInstance();
if ($_SESSION['admin'] == true && isset($_GET["aero_id"])) {
    //echo 'OK';
    $modif = $bdd->query("SELECT * FROM aeroport WHERE id_aero =" . $_GET["aero_id"] . ";");
    $aero = $modif->fetch();
    if (isset($_POST['aeroport'])) {
        try {
            $aeroport = new aeroport(addslashes($_POST['aeroport']), $aero["id_dest"]);
            $aeroport->updateAeroport($aeroport->getLibelle(), $aeroport->getDest(), $aeroport->getId());
            header("location:aeroport-liste.php");
        } catch (Exception $ex) {
            echo 'erreur lors de la modification de l\' aeroport' . $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/aeroport.php';
$bdd = connexion_db::getInstance();
session_start();
if ($_SESSION['admin'] == true) {
    //echo 'OK';
    if (isset($_POST['aeroport']) && isset($_POST['destination_name'])) {
        try {
            $aeroport = new aeroport(addslashes($_POST['aeroport']), $_POST['destination_name']);
            $aeroport->addAeroport($aeroport->getLibelle(), $aeroport->getDest());
            header("location:aeroport-liste.php");
        } catch (Exception $ex) {
            echo 'erreur lors de l\'ajout de l\' aeroport ' . $ex->getMessage() . $_POST['destination_name'];
        }
    }
} 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>
<body>
<?php