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.