为什么我的删除功能不起作用?

Why doesn't my delete function work?

我关注了 Youtube 上关于如何制作 CMS 系统的教程: http://y2u.be/QNxU3Qa6QZs

而且我坚持使用删除功能,它只是刷新页面而没有真正删除某些内容。有人可以帮我解决这个问题吗?

这是删除页面的代码:

<?php 

session_start();

include_once('../includes/connection.php');
include_once('../includes/article.php');

$article = new Article;

if (isset($_SESSION['logged_in'])) {
    if(isset($_GET['id'])) {

        $id = $GET['id'];

        $query = $pdo->prepare('DELETE FROM articles WHERE article_id = ?');
        $query->bindValue(1, $id);
        $query->execute();

        header('Location: delete.php');
    }

$articles = $article->fetch_all();

 ?>
<html>

<head>
    <title> Blog </title>
    <link rel="stylesheet" href="../assets/style.css" />
</head>

<body>
    <div class="container">
        <a href="index.php" id="logo">CMS</a>
        <br><br>

        <h4>Select an Article to delete </h4>

        <form action="delete.php" method="get">

            <select onchange="this.form.submit();" name="id">

                    <?php foreach ($articles as $article) { ?>
                    <option value="<?php echo $article['article_id']; ?>"> 
                    <?php echo $article['article_title'];   ?>

                </option>
                    <?php } ?>

                </select>
        </form>


    </div>
</body>

</html>

<?php
} else {
header('Location: index.php'); 
}

?>

如果您对代码有任何疑问,我会回答。

希望你能帮我找到解决这个问题的方法。

你打错了。

改变

$id = $GET['id'];

$id = $_GET['id']; #$_GET is the global array not $GET