37237-vm/update_process.php
Flatlogic Bot e1227cfbcd mvp.4
2026-01-02 11:42:24 +00:00

37 lines
1.2 KiB
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? null;
$name = $_POST['name'] ?? null;
$description = $_POST['description'] ?? null;
if ($id && $name && $description) {
try {
$pdo = db();
$stmt = $pdo->prepare("UPDATE processes SET name = :name, description = :description WHERE id = :id");
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
if ($stmt->execute()) {
header('Location: index.php?success=processupdated');
exit();
} else {
header('Location: index.php?error=updatefailed');
exit();
}
} catch (PDOException $e) {
error_log("DB Error: " . $e->getMessage());
header('Location: index.php?error=dberror');
exit();
}
} else {
header('Location: index.php?error=emptyfields');
exit();
}
} else {
header('Location: index.php?error=invalidrequest');
exit();
}