单击“删除”按钮后,HTML表单将发送空的$ _GET

This is a simple directory listing, which allows you to navigate and go back. Everything works until I click the "Delete" button. The form is sent, but no values appear in the URL and therefore the $_GET is empty.

This is the code that attempts to send a test value when clicking "Delete".

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Directory listing</title>
    </head>
    <body>
        <?php
        $path = empty($_GET["path"]) ? "D:/" : $_GET["path"];
        ?>
        <a href="index.php?path=<?= substr($path, 0, strrpos($path, "/", -2)) . "/" ?>"><=</a>
        <?php
        $dir = opendir($path);

        while ($fileName = readdir($dir)) :
            if ($fileName != "." && $fileName != "..") :
                ?>
                <div>
                    <?php
                    if (is_dir($path . $fileName)) :
                        ?>
                        <a href="index.php?path=<?= $path . $fileName ?>/"><?= $fileName ?></a>
                        <form style="display:inline" action="index.php?path=test" method="GET">
                            <input type="submit" value="Delete" />
                        </form>
                        <?php
                    endif;
                    if (is_file($path . $fileName)) {
                        echo "$fileName";
                    }
                    ?>
                </div>
                <?php
            endif;
        endwhile;
        ?>
    </body>
</html>

I'm using Xampp v3.2.2.

Have you try to add a slash in front of your action in here ?

<form style="display:inline" action="/index.php?path=test" method="GET">
    <input type="submit" value="Delete" />
</form>