Something like the following should work:
PHP Code:
<?php
$input = 'FOO' . "\07"; //FOO plus a BEL
// $input = 'FOO'; //uncomment for a valid response.
// print_r($input);
if (preg_match('/[^A-Za-z0-9&#\!\(\)-+\/=\?:@\'\"]/', $input)) {
echo 'Error!';
}
else {
echo 'Input Validated';
}
?>
Notice the carot in front of
A-Z. That negates the statement, so if preg_match is successful that means something other than the allowable characters was matched.
You may also want to look at the
Validate pear class. Looks like a consistent interface to validate input.
-r