(Next time, remember to use the <code> tag to enclose
your code)
It should work if you remove the negation. Right now it says
"if the username does not contain a non-alphanumeric character,
generate an error", which is exactly the opposite of what you want.
Remove the "!" and it should be corrected.
Also, remember that \w in Perl regular expressions
represents the "alphanumeric plus underscore" class, exactly
the class you used, and \W represents its complement. So you
could do the test like this:
if ($FORM{username} =~ /\W/) {
&error;
} else {
&proceed;
}
IMHO it is clearer and safer to check that the string contains only
valid characters, instead of checking if it contains invalid
ones. Like this:
if ($FORM{username} =~ /^\w+$/) {
&proceed;
} else {
&error;
}
--ZZamboni