$conn = new mysqli($servername, $username, $password, $dbname); $event_name = $_POST['event_name']; $event_date = $_POST['event_date']; $event_time = $_POST['event_time']; $event_location = $_POST['event_location']; $sql = "INSERT INTO events (event_name, event_date, event_time, event_location) VALUES ('$event_name', '$event_date', '$event_time', '$event_location')"; if ($conn->query($sql) === TRUE) { echo "Event saved successfully!"; } else { echo "Error: " . $sql . "
" . $conn->error; } $conn->close();
require_once __DIR__ . '/vendor/autoload.php'; $client = new Google_Client(); $client->setApplicationName('Google Calendar PHP API'); $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS); $client->setAuthConfig('credentials.json'); $client->setAccessType('offline'); $service = new Google_Service_Calendar($client); $event = new Google_Service_Calendar_Event([ 'summary' => 'Coffee Meeting', 'location' => 'Somewhere', 'description' => 'Discussing our new project', 'start' => [ 'dateTime' => '2022-06-10T10:00:00+01:00', 'timeZone' => 'Europe/London', ], 'end' => [ 'dateTime' => '2022-06-10T11:00:00+01:00', 'timeZone' => 'Europe/London', ], ]); $calendarId = 'primary'; $event = $service->events->insert($calendarId, $event); printf('Event created: %s\n', $event->htmlLink);In this example, the Google_Client class is used to authenticate the user and obtain an access token. The Google_Service_Calendar class is then used to create a new event with the specified details. The event is then inserted into the user's primary calendar using the events->insert method. Package library: The examples provided above make use of different package libraries. Example 1 makes use of the mysqli library and Example 2 makes use of the Google Calendar API library.