Learning PHP and MySQL

Example 10-06 Checking input from a radio button or a single select

<?php
$options  
=  array('option  1',  'option  2',  'option  3');
//  Coming  from  a  checkbox  or  a  multiple  select  statement
$valid  =  true;
if  (
is_array($_GET['input']))  {
$valid  
=  true; foreach($_GET['input']  as  $input)  if  (!in_array($input,  $options))  {
$valid  
=  false;
}
}
if  ($valid)  {
//  process  input
}
}
?>

Posted by on 08/18 at 11:05 AM

Next entry: Example 10-07 Checking input from a checkbox or a multiple select

Previous entry: Figure 10-09 Selecting Italian and Chinese

<< Back to main