I'm creating a simple PHP and SQL to do list application. My problem is, every time I edit a row, it creates another row instead of just editing the existing row. Here is some of the code from index.php:

```
<?php

$current_date = date("Y-m-d");

if ($_SERVER['REQUEST_METHOD'] == 'POST'){

$task = isset($_POST['task']) ? $_POST['task'] : null;
$importance = isset($_POST['importance']) ? $_POST['importance'] : null;
$due_date = isset($_POST['due_date']) ? $_POST['due_date'] : null;
$order = isset($_POST['order']) ? $_POST['order'] : null;

if(isset($task,$importance,$due_date,$user_name)){
$sql = "INSERT INTO tasks (task, importance, due_date, user_name) VALUES ('$task', '$importance', '$due_date', '$user_name')";

$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));

}

}

?>

<?php
while($column = mysqli_fetch_assoc($result)){
?>
<tr><td><?php echo $column["task"]?></td><td class="<?php echo $column["importance"] ?>"><?php echo $column["importance"]?></td><?php if($column["due_date"]<$current_date){echo '<td class="overdue">';}else{echo '<td class="not_overdue">';} ?><?php echo $column["due_date"]?></td><td><?php echo "<a href='edit.php?id=".base64_encode($column['task_id'])."'>Edit</a>" ?></td><td><?php echo "<a href='delete_one.php?id=".base64_encode($column['task_id'])."' onclick=\"return confirm('Are you sure?')\">Delete</a>" ?></td></tr>
<?php
}
?>

```

Here is some of the code from edit.php:

```
<?php

if($_GET['id'] != ""){

$task_id = $_GET['id'];

$task_id = base64_decode($task_id);

$sql = "SELECT * FROM tasks WHERE task_id='$task_id'";

$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));

}

?>

<?php
}
?>

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST'){

$task = isset($_POST['task']) ? $_POST['task'] : null;
$importance = isset($_POST['importance']) ? $_POST['importance'] : null;
$due_date = isset($_POST['due_date']) ? $_POST['due_date'] : null;

if(isset($task,$importance,$due_date)){

$sql = "UPDATE tasks SET task='$task', importance='$importance', due_date='$due_date' WHERE task_id='$task_id'";

$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));

}

}

?>

```

Can someone tell me what I'm doing wrong?