Usernames on my website should only contain A-Z,a-z,0-9. No spaces or special characters.
I have the following php code in my register form however when I input a username which contains only letters it outputs the error, any help?:
if (!preg_match('/[^a-zA-Z0-9]+/gm', $_POST["userName"])) {
$output = json_encode(
array(
'type' => 'error',
'text' => 'Your username must not contain any spaces or special characters.'
));
die($output);
}