There is a PHP + phpMyAdmin task list, everything seems to be correct according to the code, it does not knock out any errors, but no tasks are added to the sheet itself and the database. Here's the code, what's the problem?
<?php $errors = ""; // подключение к БД $db = mysqli_connect('localhost', 'root', 'mysql', 'todo'); if (isset($_POST['submit'])) { $task = $_POST['task']; if (empty($task)) { $errors = "Ты должен что-то записать"; } else { mysqli_query($db, "INSERT INTO tasks (task) VALUES ('$task')"); header('location: index.php'); } } // delete task if (isset($_GET['del_task'])) { $id = $_GET['del_task']; mysqli_query($db, "DELETE FROM tasks WHERE id=$id"); header('location: index.php'); } $tasks = mysqli_query($db, "SELECT * FROM tasks"); ?> <!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Лист задач с PHPMyAdmin</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="heading"> <h2>Лист задач используя MySQL</h2> </div> <form action="index.php" method="POST"> <?php if (isset($errors)) { ?> <p><?php echo $errors; ?></p> <?php } ?> <input type="text" name="task" class="task_input"> <button type="submit" class="add_btn" name="submit">Добавить задание</button> </form> <table> <thead> <tr> <th>N</th> <th>Task</th> <th>Action</th> </tr> </thead> <tbody> <?php $i = 1; while ($row = mysqli_fetch_array($tasks)) { ?> <tr> <td><?php echo $i; ?></td> <td class="task"><?php echo $row['task']; ?></td> <td class="delete"> <a href="index.php?del_task=<?php echo $row['id']; ?>">x</a> </td> </tr> <?php $i++; } ?> </tbody> </table> </body> </html> 