getConnection(); $off = new office($db); if (isset($_POST['submit'])) { // Safely access $_POST variables $off->brch_name = $_POST['brch_name'] ?? ''; $off->brch_city = $_POST['brch_city'] ?? ''; $off->brch_add = $_POST['brch_add'] ?? ''; $off->brch_code = $_POST['brch_code'] ?? ''; // Update the attendance if ($off->off_create()) { $folder_name = trim($off->brch_name); $folder_name = preg_replace("/\s+/", "", $folder_name); $file_path = 'qrcode/' . $folder_name . "/"; if (!file_exists($file_path)) { mkdir($file_path); } // Redirect with success parameter to another page (e.g., dashboard.php) header("Location: dashboard.office.view.php?success=true"); exit(); } else { // tell the user echo "Failed Submission."; } } else ?>