2
With this code I can block special characters in my input
, but I still want him to accept .
, -
and _
how to proceed?
elseif (!preg_match('/^[a-z A-Z0-9]+$/', $username)) {
echo json_encode(array(
'login' => false,
'message' => 'Existem caracteres especiais no seu nome de usuário, se estiver utilizando <strong>@</strong>, remova-o.'
));
}
Add them to the list (what content is between the brackets).
– rray
@rray [a-z A-Z0-9 . - _] thus ?
– user94336
Spaceless:
[a-zA-Z0-9_.-]
– rray
Just a question, this will also block if user tries to log in with email ?
– user94336
It will only allow the characters that are on the list, if you put a
@
will 'block' and execute theecho
andjson_encode()
– rray