<?php
/*
********************************************************************************

    filename:    pitdeleteprocess.php
    description: delete pit
    inputs:      pitId
    outputs:     none
    actions:     none
    redirection: pitlist

********************************************************************************
*/
    include 'functions.php';
/*
    ... connect to database
*/
    $conn = connectToDB();
/*
    ... get pitId
*/
    $pitId = $_GET["pitId"];
/*
    ... delete pit and return to pit list
*/
    if ($pitId != "") {
        $sql= "DELETE FROM pits WHERE pitId = $pitId";
        if (!mysqli_query($conn, $sql)) {
            error_log("Error: " . $sql . " " . mysqli_error($conn));
            header('Location: pitlist.php');
        } else {
            header('Location: pitlist.php');
        }
    } else {
            header('Location: pitlist.php');             
    }
/*
   ... close database connection
*/
    mysqli_close($conn);           
?>