My previous attempt at asking ended up being flagged as already solved. It linked to this post. After copying the code line for line
$db = new PDO('sqlite:practice.sqlite');
$db->setAttribute( PDO::AFTER_ERRMODE, PDO::ERRMODE_EXCEPTION );
$name = '';
if(isset($_POST['name'])) {
$name = $_POST['name'];
}
$password = '';
if(isset($_POST['password'])) {
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
}
$query = $db->prepare("SELECT EXISTS (SELECT * FROM users WHERE name = :name AND password = :password)");
$query->execute(array(':name' => $name, ':password' => $password));
$result = $query->fetchAll();
if(count($result) > 0) {
echo 'exists';
} else {
echo 'doesnt exist';
}
This code always echoes out "exists" whether the user exists or not. I have also attempted this with only the user name, same result. I have, as well, attempted this with only the SELECT * FROM users;, without SELECT EXISTS(...), which changed nothing.
In the original post there was an answer which offered two possible solutions. Both of these had the same result. At this point I have read about every single possible way of doing this, on and off stackoverflow. Please help me understand what I am missing here. Every single resource I've studied on this problem doesn't work.