<?php
    $article = $use->getArticleById($_GET['id']);
?>
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header bg-transparent">
                <div class="row align-items-center">
                    <div class="col">
                        <h6 class="text-uppercase text-muted ls-1 mb-1">Update Audio</h6>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form action="" method="post" enctype="multipart/form-data">
                    <div class="form-group mb-3">
                        <label for="">Title</label>
                        <input type="text" name="title" value="<?= $article['title'] ?>" required class="form-control">
                    </div>
                    <div class="form-group mb-3">
                        <label for="">Audio</label>
                        <input type="file" name="file" class="form-control">
                        <audio controls>
                                <source src="../images/thumb/<?= $article['image'] ?>">
                            </audio>
                    </div>
                     <div class="form-group mb-3">
                        <label for="">Url</label>
                        <input type="url" name="url" class="form-control" value="<?= $article['url'] ?>">
                    </div> 
                    <button type="submit" name="submit" class="btn btn-success">Update</button>
                </form>
                <?php
                if (isset($_POST['submit'])){
                    $use->update($_POST['title'],$_FILES['file'],$_POST['url'],$_GET['id']);
                    echo "<script>location='./?page=articles'</script>";
                }
                ?>
            </div>
        </div>
    </div>
</div>