so this makes me go crazy! If the username is correct then it compares the password totally fine but if the username is wrong the comparison doesn't happen and this error is thrown at me. I want to compare the database value to the one the user entered.
<?php
$nm = $_POST['nm'];
$pw = $_POST['pw'];
try{
$pdo = new PDO('mysql:host=localhost;dbname=gold-market_main', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e) {
echo "Connection failed: ".$e->getMessage();
die();
}
if($nm == null){
die("Feld darf nicht leer sein!");
} elseif(ctype_alpha($nm[0]) or ctype_digit($nm[0])){
$sql = "SELECT k_nutzername, k_passwort FROM kunden WHERE k_nutzername IN('$nm');";
$result = $pdo->query($sql);
$row = $result->fetch(PDO::FETCH_ASSOC);
if("{$row['k_nutzername']}" != $nm) {
//header("Location: login_wrongUN.html");
print("nm wrong");
} elseif("{$row['k_passwort']}" != $pw) {
//header("Location: login_wrongPW.html");
print("pw wrong");
} else {
header("Location: konto.html");
}
}else{
die("Nutzername muss mit einem buchstaben oder einer Zahl beginnen!");
}
$pdo = null;
?>