voilà la todo list que j'essaie de reproduire : http://codewithawa.com/posts/to-do-list-application-using-php-and-mysql-database
Justement, je n'arrive pas à comprendre l'intérêt de l'appel de cette variable, pour ce qui est des deux autres lignes, il semblerait que j'ai réglé le problème mais je ne suis pas sur que ma manière de rajouter : devant header soit la bonne solution
Et voici mon code complet :
<?php
session_start();
$_SESSION['user_id'] = 1;
$db = new PDO('mysql:dbname=todolist;host=localhost;port=8889', 'root', 'root');
if (isset($_POST['submit'])) {
if (empty($_POST['task']));
$query = "INSERT INTO tasks (task) VALUES ('$task') ";
header : ('location: index.php');
}
$tasks = $query = "SELECT * FROM tasks";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My personal To Do List</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<div class="heading">
<h2>Ma To Do List</h2>
</div>
<form method="post" action="index.php">
<input type="text" name="task" class="task_input">
<button type="submit" class="add_button" name="submit">Add task</button>
</form>
<table>
<thead>
<tr>
<th>N</th>
<th>Task</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td class="task">This is the first task placeholder</td>
<td class="delete">
<a href="#">o</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>