I started fresh in programming and tried to send an email using php with a csv file as an attachment. Right now, after pressing "submit", I receive an email with the necessary information, but the attached csv file is empty and I don't know why.
I've tried several things and failed and would like to know the solution from this point on:
<?php
if(isset($_POST['Absenden']))
{
    $firstname = $_POST ['firstname'];
    $lastname = $_POST ['lastname'];
    $email = $_POST ['email'];
    $phone = $_POST ['phone'];
    $job = $_POST ['job'];
    $address = $_POST ['address'];
    $message = $_POST ['message'];
    $subject= "Schüleranmeldung $firstname $lastname";
    $recipient = "mymail";
    
    $seperator = md5(time());
    $eol = "\r\n";
    // https://stackoverflow.com/questions/12301358/send-attachments-with-php-mail
    $mailheader = "From: $email " . $eol;
    $mailheader .= "MIME-Version: 1.0 " . $eol;
    $mailheader .= "Content-Type: multipart/mixed; boundary=\"" . $seperator . "\"" . $eol . $eol;
    
    /* The email body */
    
    $txt = "--" . $seperator . $eol;
    $txt .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
    $txt .= "Content-Transfer-Encoding: 7bit" . $eol;
    $txt .= "Anmerkung: \n $message \n\n Name: $lastname \n Vorname: $firstname \n Beruf: $job \n Telefonnummer: $phone \n Adresse: $address" . $eol;
    $txt .= "--" . $seperator . $eol;
    //Content of csv file (two lines)
    $csv = "Vorname,Nachname,Address,Email,Telefon,Beruf\n";
    $csv .= "$firstname,$lastname,$address,$email,$phone,$job\n";
    
    // $content = file_get_contents($file);
    $content = chunk_split(base64_encode($csv));
    
    $FileName = $lastname."-".$firstname."-".date("d-m-y-h:i:s").".txt";
    
    $txt .= "Content-Type: application/octet-stream; name=\"" .   $FileName . "\"" . $eol;
    $txt .= "Content-Transfer-Encoding: base64" . $eol;
    $txt .= "Content-Disposition: attachment" . $eol;
    $txt .= $content . $eol . $eol;
    $txt .= "--" . $seperator . "--";
        mail($recipient, $subject, $txt, $mailheader);
        echo "<pre>" . $csv . "</pre>";
        echo "<pre>" . $content . "</pre>";
} 
?>
Thanks in advance!