From e1227cfbcd186628ddfd2a650e4a6c4a27732b94 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 2 Jan 2026 11:42:24 +0000 Subject: [PATCH] mvp.4 --- add_process.php | 6 +++-- delete_process.php | 17 +++++++++---- index.php | 61 +++++++++++++++++++++++++++++++++++++++++++++- update_process.php | 11 ++++++--- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/add_process.php b/add_process.php index 0864a5e..0d35d08 100644 --- a/add_process.php +++ b/add_process.php @@ -19,11 +19,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->execute([$name, $description]); } catch (PDOException $e) { // In a real app, log this error. For now, we'll just die. - die("Database error: " . $e->getMessage()); + 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=1'); + header('Location: index.php?success=processadded'); exit; } else { // If not a POST request, redirect to the main page diff --git a/delete_process.php b/delete_process.php index 2387458..12c3a64 100644 --- a/delete_process.php +++ b/delete_process.php @@ -8,13 +8,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'])) { $pdo = db(); $stmt = $pdo->prepare("DELETE FROM processes WHERE id = :id"); $stmt->bindParam(':id', $id, PDO::PARAM_INT); - $stmt->execute(); + if ($stmt->execute()) { + header('Location: index.php?success=processdeleted'); + exit(); + } else { + header('Location: index.php?error=deletionfailed'); + exit(); + } } catch (PDOException $e) { error_log("DB Error: " . $e->getMessage()); - // Optionally, redirect with an error message + header('Location: index.php?error=dberror'); + exit(); } +} else { + header('Location: index.php?error=invalidrequest'); + exit(); } - -header('Location: index.php'); -exit(); ?> \ No newline at end of file diff --git a/index.php b/index.php index 0480963..45f8b55 100644 --- a/index.php +++ b/index.php @@ -37,6 +37,51 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); +
+ ' . $message . '
'; + } + + if (isset($_GET['error'])) { + $message = ''; + switch ($_GET['error']) { + case 'emptyfields': + $message = 'Please fill in all fields.'; + break; + case 'dberror': + $message = 'A database error occurred. Please try again.'; + break; + case 'deletionfailed': + $message = 'Failed to delete process. Please try again.'; + break; + case 'invalidrequest': + $message = 'Invalid request.'; + break; + case 'processnotfound': + $message = 'Process not found.'; + break; + default: + $message = 'An error occurred. Please try again.'; + } + echo ''; + } + ?> +
@@ -53,7 +98,7 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '');

Map a New Process

Define a process to begin analysis.

-
+
@@ -119,6 +164,20 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); diff --git a/update_process.php b/update_process.php index 2e4f0b1..8a07018 100644 --- a/update_process.php +++ b/update_process.php @@ -15,19 +15,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->bindParam(':id', $id, PDO::PARAM_INT); if ($stmt->execute()) { - header('Location: index.php?status=success&message=Process updated successfully!'); + header('Location: index.php?success=processupdated'); exit(); } else { - header('Location: edit_process.php?id=' . $id . '&status=error&message=Failed to update process.'); + header('Location: index.php?error=updatefailed'); 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())); + header('Location: index.php?error=dberror'); exit(); } + } else { + header('Location: index.php?error=emptyfields'); + exit(); } } else { - header('Location: index.php?status=error&message=Invalid request method.'); + header('Location: index.php?error=invalidrequest'); exit(); }