1
I’m trying to validate my form and capture special characters using preg_match(..., ...)
, but unsuccessfully. So much using @ or without it, returns me the following message:
Special characters detected if using @, remove it.
What’s wrong with this code?
<?php
if (isset($_POST['ttrSignin'])) {
$ttrUsername = trim(filter_input(INPUT_POST, 'ttrUsername'));
$ttrPassword = trim(filter_input(INPUT_POST, 'ttrPassword'));
if (empty($ttrUsername)) {
$error[] = 'Insira seu nome de usuário do Twitter.';
} elseif (empty($ttrPassword)) {
$error[] = 'Insira sua senha do Twitter.';
} elseif (!preg_match("/^[a-zA-Z'-]+$/", $ttrUsername)) {
$error[] = 'Caracteres especiais detectados, se tiver usando <strong>@</strong>, remova-o.';
} else {
#restante do codigo
}
?>
What do you call special characters? Single quotes and double quotes can go through regex? Several blank spaces are acceptable?
– user60252