<?php
// Include the database configuration file
include 'config.php';

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Retrieve form data
$itemName = $_POST['foodName']; // Corrected from 'foodkName'
$itemPrice = $_POST['foodPrice'];
$itemImage = basename($_FILES["foodImage"]["name"]);

// Insert data into database
$sql = "INSERT INTO menu_items (name, price, image) VALUES ('$itemName', '$itemPrice', '$itemImage')";

if ($conn->query($sql) === TRUE) {
    echo "Food item uploaded and inserted into database successfully!";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
