    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Registration Form</title>
    </head>
    <body>
    
<?php
error_reporting(E_ALL);
var_dump($_POST);
if ($_POST['submit']){
var_dump($_POST);
echo $_POST['studentid'].'<br>';
//this is the name attriubute for that text field!
echo $_POST['firstname'].'<br>';
echo $_POST['lastname'].'<br>';
echo $_POST['email'].'<br>';
//everything above should be intuitive for you...just the name attribute
//assumes that the chckbox name is transportation[]
if (is_array($_POST['transportation'])){
foreach ($_POST['transportation'] as $key=>$value){
    echo $key.' '.$value."<br>";
}
}
echo $_POST['yearsattended'].'<br>';
echo $_POST['comments'].'<br>';    
}
//echo $_POST['specific'].'<br>';
//this is an array (list) and needs to be extracted manuallay
//var_dump($_POST);
?>

    <!--
    //Madeline Trevathan
    //02/14/19
    //Chapter 2 Assignment 
    -->
    
        STICKY FORMS MAINTAIN THE VALUE OF WHAT WAS SUBMITTED INSIDE
        THEIR RESPECTIVE INPUTS! WATCH FOR THE TRICKY RADIO BUTTONS, CHECKBOXES AND SELECTS!
        
    <form action="stickyform.php" method="post">
    
        
    <label for = "studentid"><strong>Student ID:</strong></label>
    <input type="text" id="studentid" name="studentid" placeholder="Student Id" required="required" value="<?php echo $_POST['studentid'];?>"><br>
        <---THIS ONE IS EASY!
    <label for = "firstname"><strong>First Name:</strong></label>
        <---THIS ONE IS EASY!

    <input type="text" id="firstname" name="firstname" placeholder="First Name" required="required" value="<?php echo $_POST['firstname'];?>" ><br>
                <---THIS ONE IS EASY!

    <label for = "Last Name"><strong>Last Name:</strong></label>
    <input type="text" id="lastname" name="lastname" placeholder="Last Name" required="required" value="<?php echo $_POST['lastname'];?>"><br>
            <---THIS ONE IS EASY!

    <label for = "email"><strong>Email:</strong></label>
    <input type="email" id="emaill" name="email" placeholder="Email" required="required" value="<?php echo $_POST['email'];?>"><br>
    <br>        <---THIS ONE IS EASY!

    <fieldset><legend>
        
    <em>What type of degree?</em><br>
    <label for = "bach">Bachelors</label>
    <input type="radio" name = "degree" value="bachelor" id="bach" 
    <?php
    //CHECKED=CHECKED MEANS THE POST DEGREE WAS EQUAL TO THE VALUE!
    if ($_POST['degree'] == 'bachelor'){
        echo " checked='checked' ";
    }
    ?>
    >


    <label for = "ass">Associates</label>
    <input type="radio" name = "degree" value="associates" id="ass" 
    <?php
    //NOTE THE SPACES BEFORE AND AFTGER THE CHECKED...DONT WANT TO SCREW UP YOUR HTML!!!!
    if ($_POST['degree'] == 'associates'){
        echo " checked='checked' ";
    }
    ?>

    > 
    <br>
    <br>    
    
    <em>How do you commute to school?</em><br>
        
        
    <label for = "carpool">Carpool</label>
    <input type="checkbox" name = "transportation[]" value="carpool" id="carpool"
    <?php
    //CHECKS TO SEE IF CARPOOL IS IN THE ARRAY OF THE CHECKBOX POST VAR!!!
    if (in_array('carpool',$_POST['transportation'])){
        echo ' checked="checked" ';
    }
    ?>
    > 
        
    <br><label for = "personalvehicle">Personal vehicle</label><input type="checkbox" name = "transportation[]" value="personalvehicle" id="personalvehicle" <?php
        //CHECKS TO SEE IF PERSONAL VEHICLE IS IN THE ARRAY OF THE CHECKBOX POST VAR!!! NOW YOU ARE SEEING HOW IMPORTANT IS TO GIVE YOUR HTML INPUTS AN APPROPRIATE NAME!!!

    if (in_array('personalvehicle',$_POST['transportation'])){
        echo ' checked="checked" ';
    }
    ?>> 
    <br>
    <label for = "publictransportation">Public transportation</label>
    <input type="checkbox" name = "transportation[]" value="publictransportation" id="publictransportation" <?php
    if (in_array('publictransportation',$_POST['transportation'])){
        echo ' checked="checked" ';
    }
    ?>> 
    <br><label for = "other">Other</label>
    <input type="checkbox" name = "transportation[]" value="other" id="other"<?php
    if (in_array('other',$_POST['transportation'])){
        echo ' checked="checked" ';
    }
    ?>> <br>
        
    <p><em>Years attended college?</em></p>
        <select name= "yearsattended">
            <!--NOTE THE VALUE="" -->
            <option value="">Choose Below</option>
            <option value="1-2"
            <?php
            //SELECTED IS FOR DROPDOWNS...
            if ($_POST['yearsattended'] == '1-2'){
                echo ' selected="selected" ';
            }
            ?>
            >1-2 years</option> 
            <option value="3-4" 
            <?php
          if ($_POST['yearsattended'] == '3-4'){
                echo ' selected="selected" ';
            }
            ?>
            >3-4 years</option> 
            <option value="5 or more" <?php
 if ($_POST['yearsattended'] == '5 or more'){
                echo ' selected="selected" ';
            }?>
            ?>
            >5 years or more</option> 
        </select><br>
        <p><em>Total units 2019 Spring semester:</em></p>
        <textarea name="comments"><?php
        echo $_POST['comments'];
        ?></textarea><br>
        <button name="submit" value="Submit">Submit</button>
    
</legend></fieldset>
        
    </form>    








    </body>
    </html>