prepare("SELECT * FROM cars WHERE id = ? AND deleted_at IS NULL"); $stmt->execute([$id]); } else { $stmt = $pdo->prepare("SELECT * FROM cars WHERE id = ? AND user_id = ? AND deleted_at IS NULL"); $stmt->execute([$id, $userId]); } $car = $stmt->fetch(); if (!$car) { header('Location: dashboard.php'); exit; } $error = ''; $success = false; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $brand = $_POST['brand'] ?? ''; $model = $_POST['model'] ?? ''; $year = $_POST['year'] ?? ''; $price = $_POST['price'] ?? ''; $city = $_POST['city'] ?? ''; $description = $_POST['description'] ?? ''; try { $stmt = $pdo->prepare("UPDATE cars SET brand = ?, model = ?, year = ?, price = ?, city = ?, description = ?, status = 'pending' WHERE id = ?"); $stmt->execute([$brand, $model, $year, $price, $city, $description, $id]); $success = true; // Refresh car data $car['brand'] = $brand; $car['model'] = $model; $car['year'] = $year; $car['price'] = $price; $car['city'] = $city; $car['description'] = $description; } catch (Exception $e) { $error = "Update failed: " . $e->getMessage(); } } $cities = ['Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad', 'Kunduz', 'Ghazni', 'Balkh']; ?>
Update your vehicle specifications. Note: making changes will reset the approval status to 'pending'.
Your changes have been saved and the listing is awaiting re-approval by our administrators.