<?php
error_reporting(0);
$data = $_POST['web'];
foreach ($data as $value){
    $stringtotest .= $value.',';
}
//echo $stringtotest;//This is the string with all the web values that were selected
//I use strpos to see if a string is contained in another string!
//echo  strpos($stringtotest,'mysql');


if (strpos($stringtotest,'php') === false){
    echo 'PHP IS NOT IN THIS STRING';
}
else
{
     echo 'PHP IS IN THIS STRING';

}

?>
<form action="checkboxesdemo.php" method="post">
    Fullname <input type="text" name="fullname"  value="<?php
                    echo $_POST['fullname'];
        ?>"/>
                    
PHP <input type="checkbox" name="web[]"  value="php" <?php
 //this needs to be based on what was checked before the submit buttton was pressed!    
            $pos = strpos($stringtotest,'php');
           if ($pos !== false){
               echo ' checked="checked" ';
           }
           ?>/>
HTML <input type="checkbox" name="web[]"  value="html" <?php
 //this needs to be based on what was checked before the submit buttton was pressed!    
            $pos = strpos($stringtotest,'html');
           if ($pos !== false){
               echo ' checked="checked" ';
           }
           ?>/>
JavaScript <input type="checkbox" name="web[]" value="javascript" <?php
 //this needs to be based on what was checked before the submit buttton was pressed!    
            $pos = strpos($stringtotest,'javascript');
           if ($pos !== false){
               echo ' checked="checked" ';
           }
           ?>/>
MySQL <input type="checkbox" name="web[]" value="mysql" <?php
 //this needs to be based on what was checked before the submit buttton was pressed!    
         $pos = strpos($stringtotest,'mysql');
           if ($pos !== false){
               echo ' checked="checked" ';
           }
           ?>/>
    
    <select name = "year">
    <option value="">Choose Below</option>
            <option value="Freshman" <?php
                    if ($_POST['year'] == 'Freshman'){
                        echo ' selected="selected" ';
                    }
                   ?>
                >Freshman</option>
            <option value="Sophomore" <?php
                    if ($_POST['year'] == 'Sophomore'){
                        echo ' selected="selected" ';
                    }
                   ?>>Sophomore</option>
            <option value="Junior" <?php
                    if ($_POST['year'] == 'Junior'){
                        echo ' selected="selected" ';
                    }
                   ?>>Junior</option>
            <option value="Senior" <?php
                    if ($_POST['year'] == 'Senior'){
                        echo ' selected="selected" ';
                    }
                   ?>>Senior</option>

    </select>
    <br>
    <input type="radio" name="gender" value="male"
           <?php
           if ($_POST['gender'] == 'male'){
               echo ' checked="checked" ';
           }
           ?>          
           > Male<br>
    <input type="radio" name="gender" value="female"   <?php
           if ($_POST['gender'] == 'female'){
               echo ' checked="checked" ';
           }
           ?>  > Female
    <textarea name="Comments"><?php echo $_POST['Comments'];?></textarea> 
    
    
<input type="submit" name="submit" value="Submit"    />
</form>







