36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
// Basic validation
|
|
if (empty(trim($_POST['name'])) || empty(trim($_POST['description']))) {
|
|
// Redirect back with an error message if needed, but for now we just exit.
|
|
header('Location: index.php?error=emptyfields');
|
|
exit;
|
|
}
|
|
|
|
$name = trim($_POST['name']);
|
|
$description = trim($_POST['description']);
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = "INSERT INTO processes (name, description) VALUES (?, ?)";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$name, $description]);
|
|
} catch (PDOException $e) {
|
|
// In a real app, log this error. For now, we'll just die.
|
|
error_log("DB Error: " . $e->getMessage());
|
|
header('Location: index.php?error=dberror');
|
|
exit;
|
|
}
|
|
|
|
// Redirect back to the main page after successful insertion
|
|
header('Location: index.php?success=processadded');
|
|
exit;
|
|
} else {
|
|
// If not a POST request, redirect to the main page
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
?>
|