Name always comes back as too short

So, I’m trying to make it so when a user registers his or her username that it can’t be under 3 characters long, but every single time I click register it always echos the username being too short. Why is this happening?

$Host = "";
$User = "";
$Pass = "";
$Name = "";
$Data = new mysqli($Host,$User,$Pass,$Name);
if (isset(getallheaders()["Syn-User-Identifier"]) and preg_match("/(syn)/",getallheaders()["User-Agent"]) == 1) 
{
    $InputJSON = file_get_contents('php://input');
    $Input = json_decode($InputJSON, TRUE); 
    $Username = mysqli_real_escape_string($Data,$Input["Username"]);
    $Profile = mysqli_real_escape_string($Data,$Input["Profile"]);
    $HWID = mysqli_real_escape_string($Data,getallheaders()["Syn-User-Identifier"]);
    if (strlen($Username) <= 3) 
    {
        echo "Name too short";
    }
    else
    {
        if (strlen($Username) < 16) {
            $Response = $Data->query("SELECT UserId,UserName,ProfilePicture FROM UserData WHERE UserId = '$HWID' LIMIT 1");
            if ($Response->num_rows != 0) 
            {
                echo "Already registered";
            }
            else
            {
                $Response = $Data->query("INSERT INTO `UserData`(`UserId`, `UserName`, `ProfilePicture`) VALUES ('$HWID','$Username','$Profile')");
                echo "Registered successfully";
            }
        }
        else
        {
            echo "Name too long";
        }
    }
}
?>

PS: I didnt make all of this code, I just edited some of it.

Are you using PHP and JSON or just PHP?
Are you sure that you are getting a value for $Username? I would not use a capital letter for the first character as that can lead to problems and might be a reason?

I personally would not worry about a username being too long, but I would do some like the following

if (strlen($username) > 2 && strlen($username) < 16) {
  /* Continue on coding */
} else {
  echo "Username needs to be at least 3 characters long and no longer than 15 characters long";
}
Sponsor our Newsletter | Privacy Policy | Terms of Service