Show sourcecode

The following files exists in this folder. Click to view.

test/incl/blokket/

add-article.php
aside.php
blokket-default.php
data/
initiate.php
remove-article.php
show-all-articles.php
show-article.php
update-article.php

remove-article.php

1 lines ASCII Unix (LF)
1
<?php
$path = "incl/blokket/data";
$selected = "Select article";
$removed = null;
if(isset($_POST['doRemove']) && $_POST['article-selection'] != "Select article")
{
    unlink("$path/" . $_POST['article-selection']);
    $removed = true;
}
?>

<h1>Remove article</h1>
<fieldset>
    <form method="post">
        <p><label for="article-selection">Articles:</label><br>
        <select id="article-selection" name="article-selection">
            <?php
            $filenames = readDirectory($path);
            echo "<option value='Select article' selected>Select article</option>";
            $contents = null;

            foreach ($filenames as $filename)
            {
                if($selected == $filename)
                    $contents .= "<option value='" . $filename . "' selected>" . $filename . "</option>";
                else
                    $contents .=  "<option value='" . $filename . "'>" . $filename . "</option>";
            }

            echo $contents;
            ?>
        </select></p>
        <p><input type="submit" name="doRemove" value="Remove article"></p>
    </form>
    <?php if($removed == true): ?>
        <p class="success">The article was removed.</p>
    <?php endif; ?>
</fieldset>