add_material.php aktualisiert

This commit is contained in:
M_Viper 2024-02-25 15:27:10 +00:00
parent b18b33aa80
commit 21eb9a900a
1 changed files with 60 additions and 60 deletions

View File

@ -2,9 +2,6 @@
// Datenbankverbindung herstellen
include_once 'config/config.php';
// Standard-E-Mail-Adresse aus der Konfigurationsdatei
$email = $email; // Verwenden Sie hier den Variablennamen aus Ihrer config.php
$response = array(); // Array für die AJAX-Antwort
if ($_SERVER["REQUEST_METHOD"] == "POST") {
@ -14,9 +11,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$location = $_POST["location"];
$amount_should = $_POST["amount_should"];
$amount_is = $_POST["amount_is"];
$expiration_date = $_POST["expiration_date"];
$barcode = $_POST["barcode"];
// Mindesthaltbarkeitsdatum überprüfen
$expiration_date = empty($_POST["expiration_date"]) ? "00.00.0000" : $_POST["expiration_date"];
// Bildverarbeitung, falls ein Bild hochgeladen wurde
$image = null;
if ($_FILES["image"]["name"]) {
@ -41,8 +40,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
exit();
}
$sql = "INSERT INTO materials (item_name, manufacturer, location, amount_should, amount_is, expiration_date, barcode, image, email)
VALUES ('$item_name', '$manufacturer', '$location', $amount_should, $amount_is, '$expiration_date', '$barcode', '$image', '$email')";
// SQL-Abfrage mit dem Wert von $notification_days
$sql = "INSERT INTO materials (item_name, manufacturer, location, amount_should, amount_is, expiration_date, notification_days, barcode, image, email)
VALUES ('$item_name', '$manufacturer', '$location', $amount_should, $amount_is, '$expiration_date', $notification_days, '$barcode', '$image', '$email')";
if ($conn->query($sql) === TRUE) {
$response['success'] = true;