query($sqla); while ($nta = $resulta->fetch_assoc()) { if ($nta['Ortname'] == $_POST['Ort']) { exit(); } } $sqls = 'INSERT INTO Orte (ID, Ortname) VALUES (NULL, "'.$_POST['Ort'].'");'; $stmts = $db->prepare($sqls); if (!$stmts) { die ('Datensatz konnte nicht angelegt werden: '.$db->error); } if (!$stmts->execute()) { die ('Datensatz konnte nicht angelegt werden: '.$stmts->error); }