[insert_php]
if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {
$birth_location_index = $_POST[‘birth_location’] ?? null;
$current_location_index = $_POST[‘current_location’] ?? null;
$original_data = json_decode(stripslashes($_POST[‘original_data’]), true);
$data = [
'selected_birth_location' => $original_data['birth_locations'][$birth_location_index] ?? null,
'selected_current_location' => $original_data['current_locations'][$current_location_index] ?? null,
'original_data' => $original_data
];
$ch = curl_init('https://api.synchronicityy.stream/myapp/select_location/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
$response_data = json_decode($response, true);
if ($response_data['status'] === 'success') {
echo '<h2>Success</h2>';
echo '<p>Your form has been submitted successfully.</p>';
} else {
echo '<h2>Error</h2>';
echo '<p>' . htmlspecialchars($response_data['message'] ?? 'An error occurred while processing your submission.') . '</p>';
}
} else {
echo ‘
Invalid request.
‘;
}
[/insert_php]