function addNewTrainingGallery()
{
    if (!isset($_SESSION['username']) || !isset($_SESSION['admin_password'])) {
        header("index.html");
    }
    $galleryname = $_REQUEST['galleryname'];
    $training_date = date($_REQUEST['training_date']);
    $description = $_REQUEST['description'];
    $picture = $_REQUEST['picture'];
    include "../../model/traininggallery.php";
    $traininggallery = new Traininggallery();
    if (!$traininggallery->addTraininggallery($galleryname, $training_date, $description, $picture)) {
        echo '{"result": 0, "message": "Could not add new match gallery, try again"}';
        return;
    }
    echo '{"result": 0, "message": "' . $galleryname . ' has been added"}';
    return;
}
function TrainingGallery()
{
    include_once "../model/traininggallery.php";
    $galleries = new Traininggallery();
    $row = $galleries->getGalleries();
    if (!$row) {
        echo '{"result": 0, "message": "No Training gallery yet"}';
        return;
    }
    echo '{"result": 1, "galleries": [';
    while ($row) {
        echo json_encode($row);
        $row = $galleries->fetch();
        if ($row) {
            echo ",";
        }
    }
    echo "]}";
    return;
}