prepare("SELECT depart FROM hob_dir WHERE depart = ? AND direction = ?"); $stm->execute([$id, $dir]); if ($row = $stm->fetch()) { $stm = $dbh->prepare("UPDATE hob_dir SET arrivee = ? WHERE depart = ? AND direction = ?"); $stm->execute([$arrivee, $id, $dir]); } else { $stm = $dbh->prepare("INSERT INTO hob_dir(depart, direction, arrivee) VALUES (?,?,?)"); $stm->execute([$id,$dir,$arrivee]); } header("Location: locdetail.php?id=$id");