    <?php
error_reporting(0);


      if ($_POST['submit'] == 'Register' ){
          if (isset($_POST['fullname'])) echo $_POST['fullname'].'<br>';
          if (isset($_POST['gender'])) echo $_POST['gender'].'<br>';
          if (isset($_POST['year'])) echo $_POST['year'].'<br>';
          if (isset($_POST['html'])) echo $_POST['html'].'<br>';
          if (isset($_POST['php'])) echo $_POST['php'].'<br>';
          if (isset($_POST['javascript'])) echo $_POST['javascript'].'<br>';
          //this is how to deal with checkboxes!!!!!
          if (is_array($_POST['hobbies'])){
              foreach ($_POST['hobbies'] as $hobby){
                  echo $hobby.', ';
              }
          }
          echo '<br>';
        //  var_dump($_POST['hobbies']);
        //  if (isset($_POST['hobbies'])) echo $_POST['hobbies'].'<br>';
          if (isset($_POST['comments'])) echo $_POST['comments'].'<br>';
      }

    ?>
    <form action ="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    Name: <input type="text" name = "fullname" required value="<?php echo $_POST['fullname'];?> "><br>
    Gender:<br> 
    Male: <input type="radio" name="gender" value="Male" required 
         <?php
             if ($_POST['gender'] == 'Male') echo ' checked ';  ?>>
        
     Female <input type="radio" name="gender" value="Female" 
         <?php
             if ($_POST['gender'] == 'Female') echo ' checked ';            
         ?>/><br> 
    Year in School <select name ="year" required>
    <option value ="">Choose Below</option>    
    <option value ="Freshman"   
    <?php if  ($_POST['year'] == 'Freshman') 
    echo ' selected '; ?>
            >Freshman</option>
    <option value ="Sophomore"  <?php if  ($_POST['year'] == 'Sophomore') 
    echo ' selected '; ?>>Sophomore</option>
    <option value ="Junior"  <?php if  ($_POST['year'] == 'Junior') 
    echo ' selected '; ?>>Junior</option>
    <option value ="Senior"  <?php if  ($_POST['year'] == 'Senior') 
    echo ' selected '; ?>>Senior</option>
    </select><br>
        Courses you have taken:
        <input type="checkbox" name='php' value='php'  <?php if ($_POST['php'] == 'php') echo ' checked ';?>>PHP<br>  
        <input type="checkbox" name='html' value='html'  <?php if ($_POST['html'] == 'html') echo ' checked ';?>>html<br>  
        <input type="checkbox" name='javascript' value='javascript'  <?php if ($_POST['javascript'] == 'javascript') echo ' checked ';?>>JavaScript<br>  
        Hobbies:
        <input type="checkbox" name='hobbies[]' value='tennis' <?php
          if (in_array('tennis',$_POST['hobbies'])) echo ' checked ';
               
               ?>>Tennis<br>  
        <input type="checkbox" name='hobbies[]' value='baseball'                <?php      if (in_array('baseball',$_POST['hobbies'])) echo ' checked ';
 ?>
>Baseball<br>  
        <input type="checkbox" name='hobbies[]' value='Hockey'  
               <?php
               if (in_array('Hockey',$_POST['hobbies'])) echo ' checked ';
               ?>
>Hockey<br>  

        
     Comments:
    <textarea name="comments" required><?php echo $_POST['comments'];?></textarea><br>
    <input type="submit" name ="submit" value="Register">

    </form>