Learning PHP and MySQL

Example 10-07 Checking input from a checkbox or a multiple 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:06 AM

Next entry: Example 10-08 PHP feet-to-meters converter

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

<< Back to main