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

    filename:    fooddeleteprocess.php
    description: deleted food/doneness
    inputs:      foodId
    outputs:     none
    actions:     none
    redirection: foodlist.php

********************************************************************************
*/
/*
    ... connect to database
*/ 
    include 'functions.php';
    $conn = connectToDB();
/*
    ... get food id
*/
    $foodId = $_GET["foodId"];
/*
    ... delete food from database
*/
        if ($foodId != "") {
            $sql= "DELETE FROM foods WHERE foodId = $foodId";
            if (!mysqli_query($conn, $sql)) {
                error_log("Error: " . $sql . " " . mysqli_error($conn));
                header('Location: foodlist.php');
            } else {
                header('Location: foodlist.php');
            }
        } else {
                header('Location: foodlist.php');             
        }
/*
    ... close database connection
*/
    mysqli_close($conn);           
?>