<?php
// Connect to MySQL
include_once './dbconn.php';

// Clear any previous output
if (ob_get_level()) {
    ob_end_clean();
}

// Set headers to force download of CSV file
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="stafflistupload.csv"');
header('Pragma: no-cache');
header('Expires: 0');

// Open output stream
$output = fopen('php://output', 'w');

// Output CSV column headers
fputcsv($output, array('ID', 'First name', 'Middle name', 'Last Name', 'Companyname', 'Registration link', 'Phone', 'Emailaddress', 'Gender', 'Date Of Birth'));

// Close the file pointer
fclose($output);

// Ensure no additional output is sent
exit();
?>
