<?php

session_start();
include_once 'functions/fungsi.php';
include_once 'connection/koneksi.php';



if (!empty($_FILES['uploaded_file'])) {
    $path = "foto/";
    $path = $path . basename($_FILES['uploaded_file']['name']);
    if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
        echo "The file " . basename($_FILES['uploaded_file']['name']) .
        " has been uploaded";
    } else {
        echo "There was an error uploading the file, please try again!";
    }
}
$id = $_GET['id'];
//die($id);
$nama = $_POST['nama'];
$harga = $_POST['harga'];
$deskripsi = $_POST['deskripsi'];
$id_karyawan = get_session('id');
$gambar = basename($_FILES['uploaded_file']['name']);



$sql = "UPDATE menu SET nama='$nama', harga='$harga', deskripsi='$deskripsi', id_karyawan=$id_karyawan, gambar='$gambar' WHERE id=$id";

if ($database->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $database->error;
}



redirect('index.php');
?>