query($check_rank); if ($rank_result->num_rows > 0) { $error = "Rank #$rank is already assigned to another survey"; } } if (empty($error)) { // Handle image upload $allowed_types = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']; $file_type = $_FILES['image']['type']; if (!in_array($file_type, $allowed_types)) { $error = "Only JPG, PNG, and GIF images are allowed"; } else { $file_extension = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); $new_filename = uniqid() . '.' . $file_extension; $upload_path = '../uploads/' . $new_filename; if (move_uploaded_file($_FILES['image']['tmp_name'], $upload_path)) { $rank_value = $rank !== NULL ? $rank : 'NULL'; // Insert survey site $sql = "INSERT INTO survey_sites (rank, title, website_link, description, support_contact, image) VALUES ($rank_value, '$title', '$website_link', '$description', '$support_contact', '$new_filename')"; if ($conn->query($sql)) { $success = "Survey site added successfully!"; } else { $error = "Failed to add survey site: " . $conn->error; unlink($upload_path); // Delete uploaded file } } else { $error = "Failed to upload image"; } } } } } $page_title = 'Add Survey Site'; include '../includes/header.php'; ?>
← Back to Dashboard

Add New Survey Site

Rank #1 displays full-width. Ranks #2+ display 2 per row. Unranked sites display 3 per row (randomized).