PATH:
home
/
u865795251
/
domains
/
whatisnewis.com
/
public_html
/
everestentp
/
admin
/
Editing: export.php
<?php session_start(); require_once __DIR__ . '/../db.php'; if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) { header('Location: login.php'); exit; } $pdo = getDB(); $categoryFilter = $_GET['category'] ?? ''; $statusFilter = $_GET['status'] ?? ''; $where = []; $params = []; if ($categoryFilter) { $where[] = "category = ?"; $params[] = $categoryFilter; } if ($statusFilter) { $where[] = "status = ?"; $params[] = $statusFilter; } $whereClause = $where ? "WHERE " . implode(" AND ", $where) : ""; $stmt = $pdo->prepare("SELECT id, name, email, phone, company, budget, quantity, specs, message, category, form_type, status, created_at FROM inquiries $whereClause ORDER BY created_at DESC"); $stmt->execute($params); $inquiries = $stmt->fetchAll(PDO::FETCH_ASSOC); // Output headers to force download as CSV header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=Everest_Inquiries_' . date('Y-m-d') . '.csv'); $output = fopen('php://output', 'w'); // Set headers of CSV fputcsv($output, ['ID', 'Name', 'Email', 'Phone', 'Company', 'Budget', 'Quantity', 'Specifications', 'Message', 'Category', 'Form Type', 'Status', 'Date Submitted']); if (!empty($inquiries)) { foreach ($inquiries as $row) { fputcsv($output, $row); } } fclose($output); exit;
SAVE
CANCEL