37237-vm/update_process.php
Flatlogic Bot 44f71c32c4 mvp.3
2026-01-02 11:10:39 +00:00

34 lines
1.3 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?status=success&message=Process updated successfully!');
exit();
} else {
header('Location: edit_process.php?id=' . $id . '&status=error&message=Failed to update process.');
exit();
}
} catch (PDOException $e) {
error_log("DB Error: " . $e->getMessage());
header('Location: edit_process.php?id=' . $id . '&status=error&message=Database error: ' . urlencode($e->getMessage()));
exit();
}
}
} else {
header('Location: index.php?status=error&message=Invalid request method.');
exit();
}