prepare("INSERT INTO contact_info (info_type, title, content, icon, sort_order, status) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$info_type, $title, $content, $icon, $sort_order, $status]);
$message = 'Contact info added successfully.';
} elseif ($_POST['action'] == 'update') {
$id = (int)$_POST['id'];
$info_type = trim($_POST['info_type']);
$title = trim($_POST['title']);
$content = trim($_POST['content']);
$icon = trim($_POST['icon']);
$sort_order = (int)$_POST['sort_order'];
$status = in_array($_POST['status'], ['active', 'inactive']) ? $_POST['status'] : 'active';
$stmt = $pdo->prepare("UPDATE contact_info SET info_type = ?, title = ?, content = ?, icon = ?, sort_order = ?, status = ? WHERE id = ?");
$stmt->execute([$info_type, $title, $content, $icon, $sort_order, $status, $id]);
$message = 'Contact info updated successfully.';
} elseif ($_POST['action'] == 'delete') {
$id = (int)$_POST['id'];
$stmt = $pdo->prepare("DELETE FROM contact_info WHERE id = ?");
$stmt->execute([$id]);
$message = 'Contact info deleted successfully.';
}
}
} catch (Exception $e) {
$error = 'Error: ' . $e->getMessage();
}
}
// Fetch all contact info
$stmt = $pdo->query("SELECT * FROM contact_info ORDER BY sort_order ASC, created_at DESC");
$contact_infos = $stmt->fetchAll(PDO::FETCH_ASSOC);
$pageTitle = 'Manage Contact Info';
include 'includes/header.php';
?>
| ID |
Type |
Title |
Content |
Icon |
Sort Order |
Status |
Created At |
Updated At |
Actions |
| No contact info found. |
|
|
|
|
|
|
|
|
|
|