$ user = $ _ POST[' user '];
if(strlen($ user)& lt; 6 || strlen( $user)> 12 ) {
The length of user name can only be 6- 12 digits.
}
If you want to limit the length and it can only be alphanumeric, then you can use regularization.
If (! preg_match('/^\w{6, 12}$/is'){
User name must be a combination of alphanumeric underscore and 6- 12 digits.
}
As for your second question, it is estimated that there is no uniform code, otherwise it is impossible to have that kind of personality.