-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
35 lines (29 loc) · 830 Bytes
/
delete.php
File metadata and controls
35 lines (29 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Include database connection and helper functions
require_once 'config/db.php';
require_once 'includes/functions.php';
// Check if ID is provided
if (!isset($_GET['id']) || empty($_GET['id'])) {
// Redirect to index if no ID provided
header('Location: index.php');
exit;
}
$id = (int)$_GET['id'];
// Check if contact exists
$contact = getContactById($id);
if (!$contact) {
// Redirect to index if contact not found
header('Location: index.php');
exit;
}
// Delete the contact
if (deleteContact($id)) {
// Set success message in session if desired
// $_SESSION['message'] = "Contact deleted successfully.";
} else {
// Set error message in session if desired
// $_SESSION['error'] = "Failed to delete contact.";
}
// Redirect back to index
header('Location: index.php');
exit;