In my database I have a Varchar entry: zZz
Note the capital.
I am letting the use input their username and checking with the entry. But I am trying to make it go wrong by incorrecly writing the username zzz - note all lowercase.
The Mysql is saying everything is ok and it is returning true, when I am expecting it to return false. What am I doing wrong. Here is my function ($db is a valid database handle):
function IsUsername($db, $Username)
{
$stmtIsUsername = $db->prepare("SELECT Username FROM members WHERE "
. "Username = :Username");
$stmtIsUsername->execute(array(':Username' => $Username));
$ret = ($stmtIsUsername && isset($stmtIsUsername) && $stmtIsUsername->rowCount() > 0) ? true : false;
$stmtIsUsername->closeCursor(); // mysql_free_result equivalent
return $ret;
}
In my database Username = zZz
I am calling the following ($db is valid)
$userInput = $_GET['username']; // Which is "zzz"
if(IsUsername($db, $userInput))
{
echo "All is OK";
} else
{
echo "The user is not valid";
}
The echo is annoyingly "All is OK". What am I doing wrong?