View Single Post
Old 03-13-2005, 09:42 AM   #2 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
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
idx is offline   Reply With Quote