/home/techb158/workloadmatch.com/Manager
Edit: /home/techb158/workloadmatch.com/Manager/add_event.php (2004B)
'error', 'message' => 'Database connection failed: ' . mysqli_connect_error()]));
}
// Check if the request is POST and the necessary data is present
if (isset($_POST['title'], $_POST['description'], $_POST['start'], $_POST['end'], $_POST['color'])) {
// Sanitize and prepare the data
$title = $mysqli->real_escape_string($_POST['title']);
$description = $mysqli->real_escape_string($_POST['description']);
$start = $mysqli->real_escape_string($_POST['start']);
$end = $mysqli->real_escape_string($_POST['end']);
$color = $mysqli->real_escape_string($_POST['color']);
$recurrence = isset($_POST['recurrence']) ? $_POST['recurrence'] : '';
$startDate = isset($_POST['startDate']) ? $mysqli->real_escape_string($_POST['startDate']) : '';
$endDate = isset($_POST['endDate']) ? $mysqli->real_escape_string($_POST['endDate']) : '';
$dayOfWeek = isset($_POST['dayOfWeek']) ? implode(',', $_POST['dayOfWeek']) : '';
// Prepare the query
$query = "INSERT INTO Events (title, description, start, end, color, recurrence, start_date, end_date, days_of_week)
VALUES ('$title', '$description', '$start', '$end', '$color', '$recurrence', '$startDate', '$endDate', '$dayOfWeek')";
// Execute the query and check for success
if ($mysqli->query($query)) {
echo json_encode(['status' => 'success', 'message' => 'Event added successfully']);
exit;
} else {
echo json_encode(['status' => 'error', 'message' => 'Failed to add event: ' . $mysqli->error]);
exit;
}
} else {
//echo json_encode(['status' => 'error', 'message' => 'Missing required fields']);
//exit;
}
?>