dth20986 2017-05-01 01:01
浏览 33

单击“删除”按钮后,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.

  • 写回答

1条回答 默认 最新

  • dongshao4207 2017-05-01 01:15
    关注

    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>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗