$courseOption['slug'] ?? '', 'title' => $courseOption['title'] ?? '', ]; } $courseSlugs = array_column($courseOptions, 'slug'); if (empty($_SESSION['application_csrf'])) { $_SESSION['application_csrf'] = bin2hex(random_bytes(32)); } $csrfToken = $_SESSION['application_csrf']; $requestedCourse = application_clean($_GET['course'] ?? ''); $old = [ 'full_name' => '', 'phone' => '', 'email' => '', 'age' => '', 'gender' => '', 'location' => '', 'education' => '', 'institution' => '', 'occupation' => '', 'course' => in_array($requestedCourse, $courseSlugs, true) ? $requestedCourse : '', 'ai_experience' => '', 'professional_experience' => '', 'skills' => '', 'career_goal' => '', 'source' => '', 'message' => '', 'terms' => '', ]; $errors = []; $success = false; if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') { $old = [ 'full_name' => application_clean($_POST['full_name'] ?? ''), 'phone' => application_clean($_POST['phone'] ?? ''), 'email' => application_clean($_POST['email'] ?? ''), 'age' => application_clean($_POST['age'] ?? ''), 'gender' => application_clean($_POST['gender'] ?? ''), 'location' => application_clean($_POST['location'] ?? ''), 'education' => application_clean($_POST['education'] ?? ''), 'institution' => application_clean($_POST['institution'] ?? ''), 'occupation' => application_clean($_POST['occupation'] ?? ''), 'course' => application_clean($_POST['course'] ?? ''), 'ai_experience' => application_clean($_POST['ai_experience'] ?? ''), 'professional_experience' => application_clean($_POST['professional_experience'] ?? ''), 'skills' => application_clean($_POST['skills'] ?? ''), 'career_goal' => application_clean($_POST['career_goal'] ?? ''), 'source' => application_clean($_POST['source'] ?? ''), 'message' => application_clean($_POST['message'] ?? ''), 'terms' => isset($_POST['terms']) ? '1' : '', ]; $honeypot = application_clean($_POST['website'] ?? ''); $postedToken = is_string($_POST['csrf_token'] ?? null) ? $_POST['csrf_token'] : ''; if ($honeypot !== '') { $success = true; } elseif (!hash_equals($csrfToken, $postedToken)) { $errors['form'] = 'Your session expired. Please review your details and submit the form again.'; } else { if ($old['full_name'] === '') { $errors['full_name'] = 'Please enter your full name.'; } elseif (strlen($old['full_name']) > 120) { $errors['full_name'] = 'Please keep your full name under 120 characters.'; } $phoneDigits = preg_replace('/\D+/', '', $old['phone']); if ($old['phone'] === '') { $errors['phone'] = 'Please enter your phone number.'; } elseif (!preg_match('/^[0-9+\-()\s]+$/', $old['phone']) || strlen($phoneDigits) < 7) { $errors['phone'] = 'Please enter a valid phone number with at least 7 digits.'; } elseif (strlen($phoneDigits) > 20) { $errors['phone'] = 'Please enter a phone number with no more than 20 digits.'; } if ($old['email'] === '') { $errors['email'] = 'Please enter your email address.'; } elseif (!filter_var($old['email'], FILTER_VALIDATE_EMAIL) || strlen($old['email']) > 254) { $errors['email'] = 'Please enter a valid email address.'; } if ($old['age'] !== '') { if (!ctype_digit($old['age']) || (int) $old['age'] < 16 || (int) $old['age'] > 100) { $errors['age'] = 'Age must be a number between 16 and 100.'; } } if ($old['gender'] !== '' && !in_array($old['gender'], $genderOptions, true)) { $errors['gender'] = 'Please choose a valid gender option.'; } if (strlen($old['location']) > 150) { $errors['location'] = 'Please keep your location under 150 characters.'; } if ($old['education'] !== '' && !in_array($old['education'], $educationOptions, true)) { $errors['education'] = 'Please choose a valid education level.'; } if (strlen($old['institution']) > 160) { $errors['institution'] = 'Please keep the institution name under 160 characters.'; } if (strlen($old['occupation']) > 160) { $errors['occupation'] = 'Please keep your occupation under 160 characters.'; } if ($old['course'] !== '' && !in_array($old['course'], $courseSlugs, true)) { $errors['course'] = 'Please choose a valid course track.'; } foreach (['ai_experience', 'professional_experience', 'skills', 'career_goal', 'message'] as $longField) { if (strlen($old[$longField]) > 5000) { $errors[$longField] = 'Please keep this response under 5,000 characters.'; } } if ($old['source'] !== '' && !in_array($old['source'], $sourceOptions, true)) { $errors['source'] = 'Please choose a valid option.'; } if ($old['terms'] !== '1') { $errors['terms'] = 'Please agree to the Terms to continue.'; } if (!$errors) { $storageDir = __DIR__ . '/storage'; $storageFile = $storageDir . '/applications.csv'; $saved = false; if (!is_dir($storageDir)) { @mkdir($storageDir, 0775, true); } $handle = @fopen($storageFile, 'a'); if ($handle !== false) { if (flock($handle, LOCK_EX)) { $isNewFile = ftell($handle) === 0; if ($isNewFile) { fputcsv($handle, [ 'submitted_at', 'full_name', 'phone', 'email', 'age', 'gender', 'location', 'education', 'institution', 'occupation', 'course', 'ai_experience', 'professional_experience', 'skills', 'career_goal', 'source', 'message', ]); } $row = [ date('c'), $old['full_name'], $old['phone'], $old['email'], $old['age'], $old['gender'], $old['location'], $old['education'], $old['institution'], $old['occupation'], $old['course'], $old['ai_experience'], $old['professional_experience'], $old['skills'], $old['career_goal'], $old['source'], $old['message'], ]; fputcsv($handle, array_map('application_csv_value', $row)); fflush($handle); flock($handle, LOCK_UN); $saved = true; } fclose($handle); } if ($saved) { $success = true; $old = array_fill_keys(array_keys($old), ''); unset($_SESSION['application_csrf']); $_SESSION['application_csrf'] = bin2hex(random_bytes(32)); $csrfToken = $_SESSION['application_csrf']; } else { $errors['form'] = 'We could not save your application right now. Please try again in a moment.'; } } } } require __DIR__ . '/includes/header.php'; ?>

Apply Now

Please complete all required fields below to submit your candidate dossier.

Thank you, your application has been submitted

Our admissions team will review your details and contact you using the information you provided.

Back to Home

Applicant Details