Checking For Alphanumeric Characters And Getting Input From Html Form
Solution 1:
This should get you going. There is a number of issues with your code that don't stop it from working, but current wisdom is not to use CGI at all so I will roll with you.
Use
GETunless you have a good reason to usePOSTThe problem is here
if(($full_name && $user_name && $password && $new_password) eq /\A[[:alnum:]]+\z/) {You are using a Boolean
&&operation that combines the truth of the three variables, and checking whether that, as a string, is equal to the result of matching the contents of$_against that regular expression.You must check each of the variables individually, and use the binding operator
=~to test them against a regex. It is also bad form to use the POSIX character classes. I suggest you usegrep, like thismy $mismatch = grep/[^A-Z0-9]/i, $full_name, $user_name, $password, $new_password;Now,
$mismatchis true if any of the variables contain a non-alphanumeric character. (Strictly, it is set to the number of variables that have a a non-alphanumeric character, which is zero (false) if none of them do.)Then you can say
if (not $mismatch) { ... }It looks like you just need an
elsethat builds a separate page.
Post a Comment for "Checking For Alphanumeric Characters And Getting Input From Html Form"