PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]; // Connect to database try { $pdo = new PDO($dsn, $user, $pass, $options); } catch (PDOException $e) { die("Database connection failed: " . $e->getMessage()); } // Function to sanitize input function sanitize($data) { return htmlspecialchars(trim($data)); } if ($_SERVER["REQUEST_METHOD"] === "POST") { // Sanitize and assign POST data $firstName = sanitize($_POST['form_fields']['name'] ?? ''); $lastName = sanitize($_POST['form_fields']['field_0c8a6e4'] ?? ''); $email = sanitize($_POST['form_fields']['email'] ?? ''); $address = sanitize($_POST['form_fields']['field_b4abae4'] ?? ''); $phone = sanitize($_POST['form_fields']['field_6bf8ffa'] ?? ''); $servingPersonnel = sanitize($_POST['form_fields']['field_55c3631'] ?? ''); $formFor = sanitize($_POST['form_fields']['field_fd06bf8'] ?? ''); $country = sanitize($_POST['form_fields']['field_dbb72a2'] ?? ''); $vacationDuration = sanitize($_POST['form_fields']['field_0649919'] ?? ''); $personnelFirstName = sanitize($_POST['form_fields']['field_c1e90e6'] ?? ''); $personnelLastName = sanitize($_POST['form_fields']['field_eb18ae1'] ?? ''); $idCardNumber = sanitize($_POST['form_fields']['field_09e6bc4'] ?? ''); $additionalMessage = sanitize($_POST['form_fields']['field_dce66f8'] ?? ''); // Basic validation if (!$firstName || !$lastName || !$email || !$address || !$phone || !$servingPersonnel || !$formFor || !$country || !$vacationDuration || !$personnelFirstName || !$personnelLastName || !$idCardNumber) { $errorMessage = "Please fill all required fields."; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errorMessage = "Please enter a valid email address."; } else { // Insert data into database $sql = "INSERT INTO un_applications (first_name, last_name, email, address, phone, serving_personnel, form_for, country, vacation_duration, personnel_first_name, personnel_last_name, id_card_number, additional_message) VALUES (:first_name, :last_name, :email, :address, :phone, :serving_personnel, :form_for, :country, :vacation_duration, :personnel_first_name, :personnel_last_name, :id_card_number, :additional_message)"; $stmt = $pdo->prepare($sql); try { $stmt->execute([ ':first_name' => $firstName, ':last_name' => $lastName, ':email' => $email, ':address' => $address, ':phone' => $phone, ':serving_personnel' => $servingPersonnel, ':form_for' => $formFor, ':country' => $country, ':vacation_duration' => $vacationDuration, ':personnel_first_name' => $personnelFirstName, ':personnel_last_name' => $personnelLastName, ':id_card_number' => $idCardNumber, ':additional_message' => $additionalMessage ]); // Prepare email $subject = "New UN Application Submission"; $message = "New application details:\r\n"; $message .= "First Name: $firstName\r\n"; $message .= "Last Name: $lastName\r\n"; $message .= "Email: $email\r\n"; $message .= "Address: $address\r\n"; $message .= "Phone: $phone\r\n"; $message .= "Serving Personnel with UN: $servingPersonnel\r\n"; $message .= "Form for: $formFor\r\n"; $message .= "Serving Country: $country\r\n"; $message .= "Vacation Duration: $vacationDuration\r\n"; $message .= "Personnel First Name: $personnelFirstName\r\n"; $message .= "Personnel Last Name: $personnelLastName\r\n"; $message .= "ID Card Number: $idCardNumber\r\n"; $message .= "Additional Message: $additionalMessage\r\n"; $headers = "From: no-reply@yourdomain.com\r\n"; $headers .= "Reply-To: $email\r\n"; // Send email mail($toEmail, $subject, $message, $headers); $successMessage = "Your application has been submitted successfully. We will get back to you via your email provided."; // Clear form fields after successful submission to prevent resubmission $_POST = []; } catch (PDOException $e) { $errorMessage = "Failed to submit application: " . $e->getMessage(); } } } // Function to retain old field values on error function old($name) { return htmlspecialchars($_POST['form_fields'][$name] ?? ''); } ?> Apply - United Nations Skip to content

Apply for Leave

UN Vacation Portal

This portal was created solely for Our Men and Women who are fighting to keep Citizens of various countries safe.
The United Nations is committed to ensuring that our Troops return back home to their families and loved ones.

Fill out your application

NB: It is an offense, punishable under the United Nations Code of Conduct, to willfully submit false information with the intention to mislead.