'/var/www/html/app_ad.png', // Note: I noticed a potential mismatch in your logic, but keeping your structure 'app_ad' => '/var/www/html/app_ad.png', 'app_logo' => '/var/www/html/app_logo.png' ]; $errors = []; // Handle File Uploads foreach ($upload_paths as $input_name => $destination) { if (isset($_FILES[$input_name]) && $_FILES[$input_name]['error'] == 0) { $ext = pathinfo($_FILES[$input_name]['name'], PATHINFO_EXTENSION); if (strtolower($ext) !== 'png') { $errors[] = "File for $input_name must be a PNG."; } else { if (!move_uploaded_file($_FILES[$input_name]['tmp_name'], $destination)) { $errors[] = "Failed to upload $input_name."; } } } } // Handle Text Fields $text_fields = [ 'channel_name', 'office_address', 'contact_details', 'enforcement_officer', 'eo_contact_details', 'company_name', 'cin_number', 'gstin_number' ]; $data_to_save = []; foreach ($text_fields as $field) { $data_to_save[$field] = $_POST[$field] ?? ''; } // Save if no errors occurred if (empty($errors)) { file_put_contents($json_file, json_encode($data_to_save, JSON_PRETTY_PRINT)); // Redirect to the same page to refresh the data and clear POST state header("Location: " . $_SERVER['PHP_SELF']); exit; } else { $error_message = implode("
", $errors); } } // --- 2. Load Data for Display --- $saved_data = []; if (file_exists($json_file)) { $json_content = file_get_contents($json_file); $saved_data = json_decode($json_content, true) ?? []; } function getValue($data, $key) { return $data[$key] ?? ''; } // Now we can safely start sending HTML include 'header.php'; ?>

Company Information Entry

Upload Ad (PNG)

Current:

Upload Logo (PNG)

Current: