"> // If URL contains &, first pass: & → & second pass: & → & // Result: Broken URL that doesn't work. // // BUG #3 (Open Redirect): // htmlspecialchars() only prevents XSS, NOT open redirects. // An attacker could craft: // terms.php?from=enrollment&return=https://evil.com/phishing // The form would submit to the malicious URL. // // AFTER: Validate URL is internal path-only, encode ONLY at output time. $returnUrl = 'enrollment-form.php'; // Safe default if (isset($_GET['return']) && is_string($_GET['return'])) { $rawReturn = trim($_GET['return']); // Only allow safe relative paths: // - No protocol (://) // - No protocol-relative (//) // - No backslashes (path traversal) // - Only alphanumeric, hyphens, underscores, dots, slashes, and query chars if ( !empty($rawReturn) && strpos($rawReturn, '://') === false && strpos($rawReturn, '//') !== 0 && strpos($rawReturn, '\\') === false && substr($rawReturn, 0, 1) !== '/' && preg_match('/^[a-zA-Z0-9\-_\.\/\?&=%]+$/', $rawReturn) ) { // Whitelist allowed pages $allowedPages = [ 'enrollment-form.php', 'courses.php', 'index.php' ]; // Extract base filename for whitelist check $basePage = strtok($rawReturn, '?'); if (in_array($basePage, $allowedPages, true)) { $returnUrl = $rawReturn; // Store raw — encode only at output } } } // ========== END FIX #2 & #3 ========== // ========== FIX #4 & #5: Terms acceptance with session storage & CSRF ========== // BEFORE: Form used method="GET" with hidden field terms_accepted=1 // and redirected via form action to the return URL. // BUG #4: Anyone could bypass by typing enrollment-form.php?terms_accepted=1 // BUG #5: No CSRF token — form submission could be forged by a malicious site. // // AFTER: - POST form with CSRF token // - Store acceptance in $_SESSION (can't be spoofed via URL) // - Validate CSRF before accepting // Generate CSRF token if not exists if (empty($_SESSION['terms_csrf_token'])) { $_SESSION['terms_csrf_token'] = bin2hex(random_bytes(32)); } $csrfToken = $_SESSION['terms_csrf_token']; // Handle POST — Terms Acceptance if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['accept_terms'])) { $submittedToken = $_POST['csrf_token'] ?? ''; if (!empty($submittedToken) && hash_equals($csrfToken, $submittedToken)) { // Valid submission — store in session $_SESSION['terms_accepted'] = true; $_SESSION['terms_accepted_at'] = date('Y-m-d H:i:s'); // Regenerate CSRF token after use (one-time use) $_SESSION['terms_csrf_token'] = bin2hex(random_bytes(32)); // Redirect to enrollment form header('Location: ' . $returnUrl); exit; } else { $csrfError = 'Security token expired. Please try again.'; } } // ========== END FIX #4 & #5 ========== ?>
Please read these terms carefully before enrolling
Last updated: April 07, 2026By enrolling in Skills Way Vocational Institute ("the Institute"), you acknowledge that you have read, understood, and agree to be bound by these Terms and Conditions. These terms constitute a legally binding agreement between you and the Institute.
Enrollment at Skills Way Vocational Institute is subject to the following conditions:
All financial obligations must be met according to the following terms:
All students are expected to maintain professional conduct:
To successfully complete a course and receive certification:
Refunds are processed according to the following schedule:
The Institute's liability is limited as follows:
Your privacy is important to us:
For questions, concerns, or clarifications regarding these terms, please contact us:
Email:
skillswayvocational@gmail.com
Phone:
Contact Support
Address:
Khanpur, Pakistan
Vocational Training Institute
Office Hours:
Mon-Sat: 9:00 AM - 5:00 PM