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

    </form>