明确表单提交然后下载

Users enter a unique code on our site in order to download a particular file (linked to that code). All works well, however, I would like the form to be reset after submit.

This is the code.

if($_POST['submit']) {

    include_once('php/connect.php');

    if(!isset($_POST['akkoord'])){

        ?>

    <script>alert ('U moet zich akkoord verklaren met de licentieovereenkomt om te scores en partijen te kunnen downloaden en te mogen gebruiken!');</script>

    <?php

    }else{


        $uniekecode = mysqli_real_escape_string($dbc, $_POST['code']);

        $q = "SELECT * FROM downloadleerkracht where code = '$uniekecode'";
    $run = mysqli_query ($dbc, $q);
    $row = mysqli_fetch_assoc($run);
    $num = mysqli_num_rows($run);
    $filename=$row['file'];

    if($num == 1){

        ?>

    <script>

$('#downloadform')[0].reset();

</script>

    <?php   

        header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
readfile ("bestanden/$filename");
$update = "UPDATE downloadleerkracht SET gedownload='1', akkoord='1', date=NOW() WHERE code='$uniekecode'";
                $runupdate = mysqli_query($dbc, $update);



exit();

    }else{

        ?>

    <script>alert ('Dit is geen geldige code!');</script>

    <?php

    }


    }}

?>

A download is forced, but the code entered by the user stays in the input field, despite the

<script>

$('#downloadform')[0].reset();

</script>