$result = mysql_query("SELECT COUNT(*) FROM `users_tbl` WHERE `userName` = '$name' AND `password` = '$pass'"); if (!$result || mysql_num_rows($result) <= 0) { // NO user found! } else { // User found and password matches }