Menu
I have a PHP Function to validate Username, I have no errors but the same username keeps getting submitted into the Database no matter how.
Here is the Code for the Function;
functionCheckUsernameExistsOrNot($Username)
{ global $conn;
$sql = "SELECT username FROM admins WHERE username=:userName";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':userName', $Username);
$stmt->execute();
$Result = $stmt->rowCount();
if ($Result==1) {return true;
} else {
return false;
}
}
And here is the Error Validation Code;
elseif (CheckUsernameExistsOrNot($Username)) {
$_SESSION["error"] = "Try another Username!";
Redirect_to("admins.php");
}