I have this code and would like to restrict the characters to [a-f][A-F][0-9]
$code = mysql_real_escape_string($_POST['dgt']);
$len = strlen($code);
if (!($len == "32" or $len == "40")) {
print "This is not a valid code.";
} else {
echo 'success';
}
right now it has a character LENGTH limit and would like to add characters restriction as stated above.
what's the best possible way to achieve this?