my drag and drop or click area is not working. if i either drag or drop or click not happen, please help debugged and fix so that it works . code below note:i did not paste all the html i only paste drag and drop or click html part hasPermission('can_create') && !$auth->hasPermission('can_edit') && !$auth->hasRole('super_admin')) { $_SESSION['error'] = "You don't have permission to access this page"; header('Location: dashboard.php'); exit; } $current_user = $auth->getCurrentUser(); $is_edit = isset($_GET['id']); $property = null; if ($is_edit) { $id = (int)$_GET['id']; $property = $db->fetchOne("SELECT * FROM properties WHERE id = ?", [$id]); if (!$property) { $_SESSION['error'] = "Property not found"; header('Location: properties.php'); exit; } $page_title = 'Edit Property'; } else { $page_title = 'Add New Property'; } // Get categories $categories = $db->fetchAll("SELECT * FROM categories WHERE type = 'property' AND status = 'active' ORDER BY name"); // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit'])) { $errors = []; // Validate input $title = trim($_POST['title']); $description = trim($_POST['description']); $category_id = (int)$_POST['category_id']; $property_type = $_POST['property_type']; $transaction_type = $_POST['transaction_type']; $price = (float)$_POST['price']; $yearly_rent = !empty($_POST['yearly_rent']) ? (float)$_POST['yearly_rent'] : null; $monthly_rent = !empty($_POST['monthly_rent']) ? (float)$_POST['monthly_rent'] : null; $size_sqft = !empty($_POST['size_sqft']) ? (int)$_POST['size_sqft'] : null; $bedrooms = !empty($_POST['bedrooms']) ? (int)$_POST['bedrooms'] : null; $bathrooms = !empty($_POST['bathrooms']) ? (int)$_POST['bathrooms'] : null; $address = trim($_POST['address']); $city = trim($_POST['city']); $state = trim($_POST['state']); $location_area = trim($_POST['location_area']); $latitude = !empty($_POST['latitude']) ? (float)$_POST['latitude'] : null; $longitude = !empty($_POST['longitude']) ? (float)$_POST['longitude'] : null; $status = $_POST['status']; $featured = isset($_POST['featured']) ? 1 : 0; // Validate required fields if (empty($title)) $errors[] = "Title is required"; if (empty($property_type)) $errors[] = "Property type is required"; if (empty($transaction_type)) $errors[] = "Transaction type is required"; if ($price <= 0) $errors[] = "Valid price is required"; if (empty($address)) $errors[] = "Address is required"; if (empty($city)) $errors[] = "City is required"; if (empty($state)) $errors[] = "State is required"; // Handle features and amenities $features = isset($_POST['features']) ? array_filter($_POST['features']) : []; $amenities = isset($_POST['amenities']) ? array_filter($_POST['amenities']) : []; // Handle image uploads $images = []; $existing_images = $is_edit ? json_decode($property['images'], true) ?? [] : []; if (!empty($_FILES['images']['name'][0])) { foreach ($_FILES['images']['tmp_name'] as $key => $tmp_name) { if ($_FILES['images']['error'][$key] === UPLOAD_ERR_OK) { $file_name = $_FILES['images']['name'][$key]; $file_size = $_FILES['images']['size'][$key]; $file_tmp = $_FILES['images']['tmp_name'][$key]; $file_type = $_FILES['images']['type'][$key]; // Validate file if (!in_array($file_type, ALLOWED_IMAGE_TYPES)) { $errors[] = "Invalid image type: $file_name"; continue; } if ($file_size > MAX_FILE_SIZE) { $errors[] = "File too large: $file_name"; continue; } // Generate unique filename $extension = pathinfo($file_name, PATHINFO_EXTENSION); $new_filename = 'property_' . uniqid() . '_' . time() . '.' . $extension; $upload_path = PROPERTY_UPLOAD_DIR . '/' . $new_filename; if (move_uploaded_file($file_tmp, $upload_path)) { $images[] = 'uploads/properties/' . $new_filename; } } } } // Combine with existing images if editing if ($is_edit) { $images = array_merge($existing_images, $images); } if (empty($images) && !$is_edit) { $errors[] = "At least one property image is required"; } if (empty($errors)) { try { $slug = Security::generateSlug($title); // Check if slug exists $slug_check = $db->fetchOne("SELECT id FROM properties WHERE slug = ? AND id != ?", [$slug, $id ?? 0]); if ($slug_check) { $slug .= '-' . time(); } if ($is_edit) { // Update property $sql = "UPDATE properties SET title = ?, slug = ?, description = ?, category_id = ?, property_type = ?, transaction_type = ?, price = ?, yearly_rent = ?, monthly_rent = ?, size_sqft = ?, bedrooms = ?, bathrooms = ?, address = ?, city = ?, state = ?, location_area = ?, latitude = ?, longitude = ?, features = ?, amenities = ?, images = ?, status = ?, featured = ?, updated_at = NOW() WHERE id = ?"; $db->execute($sql, [ $title, $slug, $description, $category_id, $property_type, $transaction_type, $price, $yearly_rent, $monthly_rent, $size_sqft, $bedrooms, $bathrooms, $address, $city, $state, $location_area, $latitude, $longitude, json_encode($features), json_encode($amenities), json_encode($images), $status, $featured, $id ]); $_SESSION['success'] = "Property updated successfully"; } else { // Insert new property $sql = "INSERT INTO properties ( title, slug, description, category_id, property_type, transaction_type, price, yearly_rent, monthly_rent, size_sqft, bedrooms, bathrooms, address, city, state, location_area, latitude, longitude, features, amenities, images, status, featured, created_by ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $db->execute($sql, [ $title, $slug, $description, $category_id, $property_type, $transaction_type, $price, $yearly_rent, $monthly_rent, $size_sqft, $bedrooms, $bathrooms, $address, $city, $state, $location_area, $latitude, $longitude, json_encode($features), json_encode($amenities), json_encode($images), $status, $featured, $current_user['id'] ]); $_SESSION['success'] = "Property added successfully"; } header('Location: properties.php'); exit; } catch (Exception $e) { $errors[] = "Database error: " . $e->getMessage(); } } } include 'includes/header.php'; ?>
Basic Information
Property Details
Location Details
Property Images
Drag and drop your images here

or click to browse

Property
####i do not paste rest html code###