清除表格提交,然后下载

时间:2018-07-27 17:22:31

标签: javascript php jquery

用户在我们的网站上输入唯一代码即可下载特定文件(链接到该代码)。一切正常,但是,我希望在提交后重新设置表格。

这是代码。

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

    }


    }}

?>

强制进行下载,但是尽管

,但用户输入的代码仍保留在输入字段中
<script>

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

</script>

0 个答案:

没有答案