-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateMeeting.php
36 lines (29 loc) · 1.35 KB
/
CreateMeeting.php
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
<?php
include "Conx.php";
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Methods: POST');
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = json_decode(file_get_contents('php://input'), true);
if (isset($data['farmerId'], $data['eventTitle'], $data['startDate'], $data['startTime'], $data['endTime'], $data['location'])) {
$farmerId = $data['farmerId'];
$eventTitle = $data['eventTitle'];
$startDate = $data['startDate'];
$startTime = $data['startTime'];
$endTime = $data['endTime'];
$location = $data['location'];
$stmt = $conn->prepare("INSERT INTO meetings (farmer_id, event_title, start_date, start_time, end_time, location) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("isssss", $farmerId, $eventTitle, $startDate, $startTime, $endTime, $location);
if ($stmt->execute()) {
echo json_encode(['success' => true, 'message' => 'Meeting created successfully']);
} else {
echo json_encode(['success' => false, 'message' => 'Failed to create meeting']);
}
$stmt->close();
} else {
echo json_encode(['success' => false, 'message' => 'Invalid input']);
}
}
$conn->close();
?>