PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
session_start();
require '../db.php';
if (!isset($_SESSION['admin_logged_in'])) { header('Location: login.php'); exit; }
$id = $_GET['id'] ?? null;
$title = ''; $goal = ''; $raised = ''; $desc = '';
// Fetch Data if Editing
if ($id) {
$stmt = $pdo->prepare("SELECT * FROM campaigns WHERE campaign_id = ?");
$stmt->execute([$id]);
$c = $stmt->fetch();
if ($c) {
$title = $c['title'];
$goal = $c['goal_amount'];
$raised = $c['raised_amount'];
$desc = $c['description'];
}
}
// Handle Submit
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'];
$goal = $_POST['goal'];
$raised = $_POST['raised']; // Allows manual update of raised amount
$desc = $_POST['description'];
// Auto-generate slug
$slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $title)));
if ($id) {
// Update
$sql = "UPDATE campaigns SET title=?, goal_amount=?, raised_amount=?, description=? WHERE campaign_id=?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$title, $goal, $raised, $desc, $id]);
} else {
// Insert
$sql = "INSERT INTO campaigns (title, slug, goal_amount, raised_amount, description) VALUES (?, ?, ?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$title, $slug, $goal, $raised, $desc]);
}
header("Location: campaigns.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit Campaign - Global Relief Bridge</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root { --primary-green: #8ac926; --dark-green: #070767; --bg-light: #f4f7f6; }
body { background: var(--bg-light); font-family: 'Segoe UI', sans-serif; display: flex; }
.sidebar { width: 260px; background: var(--dark-green); color: white; min-height: 100vh; padding: 30px; }
.main-content { flex: 1; padding: 40px; }
.editor-card { background: white; padding: 30px; border-radius: 20px; max-width: 600px; margin: 0 auto; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: bold; color: #555; }
input, textarea { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 10px; font-size: 1rem; }
.btn-save { background: var(--primary-green); color: white; border: none; padding: 12px 30px; border-radius: 30px; font-weight: bold; cursor: pointer; width: 100%; }
.btn-save:hover { background: #76b020; }
.back-link { display: inline-block; margin-bottom: 20px; color: #666; text-decoration: none; }
</style>
</head>
<body>
<div class="sidebar"><h3>Admin Panel</h3></div>
<div class="main-content">
<a href="campaigns.php" class="back-link"><i class="fas fa-arrow-left"></i> Back to Campaigns</a>
<div class="editor-card">
<h2 style="margin-bottom: 20px; color: var(--dark-green);"><?php echo $id ? 'Edit Campaign' : 'Create Campaign'; ?></h2>
<form method="POST">
<div class="form-group">
<label>Campaign Title</label>
<input type="text" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
</div>
<div class="form-group">
<label>Goal Amount (£)</label>
<input type="number" name="goal" step="0.01" value="<?php echo htmlspecialchars($goal); ?>" required>
</div>
<div class="form-group">
<label>Total Raised (£)</label>
<input type="number" name="raised" step="0.01" value="<?php echo htmlspecialchars($raised); ?>">
<small style="color:#999">Update this manually if you receive offline cash donations.</small>
</div>
<div class="form-group">
<label>Description</label>
<textarea name="description" rows="4"><?php echo htmlspecialchars($desc); ?></textarea>
</div>
<button type="submit" class="btn-save">Save Campaign</button>
</form>
</div>
</div>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E