-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_reminder.php
More file actions
40 lines (36 loc) · 1.03 KB
/
Copy pathget_reminder.php
File metadata and controls
40 lines (36 loc) · 1.03 KB
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
36
37
38
39
40
<?php
/**
* Get Reminder
*
* This script handles AJAX requests to fetch a single reminder's data based on its ID.
*/
require 'session_config.php';
require 'dbcon.php';
// Check if the user is logged in
if (!isset($_SESSION['username'])) {
header('Content-Type: application/json');
echo json_encode(['error' => 'Authentication required.']);
exit;
}
header('Content-Type: application/json');
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
$stmt = $con->prepare("SELECT * FROM reminders WHERE id = ?");
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
$result = $stmt->get_result();
$reminder = $result->fetch_assoc();
if ($reminder) {
// Return the reminder details as JSON
echo json_encode($reminder);
} else {
echo json_encode(['error' => 'Reminder not found']);
}
} else {
echo json_encode(['error' => 'Error executing query']);
}
$stmt->close();
} else {
echo json_encode(['error' => 'Invalid request']);
}
?>