This commit is contained in:
Flatlogic Bot 2025-10-17 11:07:59 +00:00
parent f400adcf7c
commit ac0f115fb6
3 changed files with 44 additions and 1 deletions

View File

@ -86,12 +86,13 @@ try {
<th>Referrer</th> <th>Referrer</th>
<th>GCLID</th> <th>GCLID</th>
<th>FBCLID</th> <th>FBCLID</th>
<th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if (empty($attendees)): ?> <?php if (empty($attendees)): ?>
<tr> <tr>
<td colspan="16" class="text-center">No attendees yet.</td> <td colspan="17" class="text-center">No attendees yet.</td>
</tr> </tr>
<?php else: ?> <?php else: ?>
<?php foreach ($attendees as $attendee): ?> <?php foreach ($attendees as $attendee): ?>
@ -112,6 +113,12 @@ try {
<td><?= htmlspecialchars($attendee['referrer']) ?></td> <td><?= htmlspecialchars($attendee['referrer']) ?></td>
<td><?= htmlspecialchars($attendee['gclid']) ?></td> <td><?= htmlspecialchars($attendee['gclid']) ?></td>
<td><?= htmlspecialchars($attendee['fbclid']) ?></td> <td><?= htmlspecialchars($attendee['fbclid']) ?></td>
<td>
<form action="delete_attendee.php" method="POST" onsubmit="return confirm('Are you sure you want to delete this attendee?');">
<input type="hidden" name="id" value="<?= $attendee['id'] ?>">
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>

26
delete_attendee.php Normal file
View File

@ -0,0 +1,26 @@
<?php
session_start();
// If the user is not logged in as admin, do nothing.
if (!isset($_SESSION['user']) || $_SESSION['user'] !== 'admin') {
header('HTTP/1.1 403 Forbidden');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'])) {
require_once 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->prepare('DELETE FROM attendees WHERE id = :id');
$stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
$stmt->execute();
} catch (PDOException $e) {
// In a real app, you'd log this error.
// For this example, we'll just stop execution.
die("Database error: " . $e->getMessage());
}
}
// Redirect back to the admin page
header('Location: admin.php');
exit;

View File

@ -171,6 +171,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<a href="index.php" style="color: #f6e05e; text-decoration: underline;">Back to Home</a> <a href="index.php" style="color: #f6e05e; text-decoration: underline;">Back to Home</a>
</div> </div>
</div> </div>
<?php elseif ($error_message && strpos($error_message, 'You are already registered') !== false): ?>
<div class="success-message">
<h1>Already Registered</h1>
<p><?= htmlspecialchars($error_message) ?></p>
<p>You can view webinar details on your dashboard.</p>
<div style="margin-top: 2rem;">
<a href="dashboard.php" style="color: #f6e05e; text-decoration: underline;">Go to Dashboard</a>
<a href="index.php" style="color: #f6e05e; text-decoration: underline; margin-left: 1rem;">Back to Home</a>
</div>
</div>
<?php else: ?> <?php else: ?>
<?php if ($error_message): ?> <?php if ($error_message): ?>
<div class="error-message"><?= htmlspecialchars($error_message) ?></div> <div class="error-message"><?= htmlspecialchars($error_message) ?></div>