//validate data: required fields cannot be empty.
 //data will be stripped of unsafe values such as html tags
 //(mysql injection checks are made upon submitting
 //the entire form rather than on each of the pages). radio and checkbox list
 //values must be on the allowed array of options (to help prevent spoofing).
 $wiseIntakeDemoGender = wise_validate('wiseIntakeDemoGender', 'You must select a Gender!');
 $wiseIntakeDemoDateOfBirth = wise_validate('wiseIntakeDemoDateOfBirth', 'Date of Birth cannot be empty!');
 $wiseIntakeDemoPrimaryPhoneNumber = wise_validate('wiseIntakeDemoPrimaryPhoneNumber', 'Primary Phone Number cannot be empty!');
 $wiseIntakeDemoPreferredEmail = wise_validate('wiseIntakeDemoPreferredEmail', 'Preferred Email cannot be empty!');
 $wiseIntakeDemoRace = wise_validate('wiseIntakeDemoRace', 'You must select a Race!');
 $wiseIntakeDemoDisability = wise_validate('wiseIntakeDemoDisability', 'You must select Yes or No!');
 $wiseIntakeDemoPellGrant = wise_validate('wiseIntakeDemoPellGrant', 'You must select Yes, No, or I do not know!');
 $wiseIntakeDemoTAA = wise_validate('wiseIntakeDemoTAA', 'You must select Yes, No, or I do not know!');
 $wiseIntakeDemoEligibleVeteran = wise_validate('wiseIntakeDemoEligibleVeteran', 'You must select Yes or No!');
 $wiseIntakeDemoSpouseOfEligibleVeteran = wise_validate('wiseIntakeDemoSpouseOfEligibleVeteran', 'You must select Yes or No!');
 $wiseIntakeEmploymentStatus = wise_validate('wiseIntakeEmploymentStatus', 'You must select your current Employment Status!');
 //optional data is just cleaned rather than checked for emptiness.
 $wiseIntakeEmployerName = wise_clean_data($_POST['wiseIntakeEmployerName']);
 //optional string
 $wiseIntakeEmploymentStartDate = wise_clean_data($_POST['wiseIntakeEmploymentStartDate']);
 //optional string
 $wiseIntakeEmploymentHoursPerWeek = wise_clean_data($_POST['wiseIntakeEmploymentHoursPerWeek']);
 //optional string
 $wiseIntakeEmploymentCurrentSalary = wise_clean_data($_POST['wiseIntakeEmploymentCurrentSalary']);
 //optional string
 //verify information checkbox was checked during variable assignment.
 //validate the date of birth field to make sure it is in mm/dd/yyyy format.
 if (!validateDate($wiseIntakeDemoDateOfBirth, 'm/d/Y')) {
     $errorArray['wiseIntakeDemoDateOfBirth'] = '<span class="form-error">Invalid date! Use mm/dd/yyyy format!</span>';
 }
 //validate the date of start date field to make sure it is in mm/yyyy format.
 $wiseIntakeEduGoal = wise_validate('wiseIntakeEduGoal', 'You must select a Goal!');
 $wiseIntakeEduCurrentStatus = wise_validate('wiseIntakeEduCurrentStatus', 'You must select your Current Status!');
 //intended programs was checked during variable assignment
 //check radio/checkbox data to make sure it is in the allowed array of options. (helps prevent spoofing)
 //only add the error if we know there is no current error for this input.
 wise_validate_radio_checkbox_spoofing($wiseIntakeEduBackground, 'wiseIntakeEduBackground', $eduBackgroundRadio);
 wise_validate_radio_checkbox_spoofing($wiseIntakeEduGoal, 'wiseIntakeEduGoal', $eduGoalRadio);
 wise_validate_radio_checkbox_spoofing($wiseIntakeEduCurrentStatus, 'wiseIntakeEduCurrentStatus', $eduCurrentStatusRadio);
 //for the checkbox list, check each selected option to make sure it is on the list of actual options.
 //note that if the array is empty, no error will be added here.
 foreach ($wiseIntakeIntendedPrograms as $SelectedIntendedProgramOption) {
     wise_validate_radio_checkbox_spoofing($SelectedIntendedProgramOption, 'wiseIntakeIntendedPrograms', $intendedProgramsCheckboxes);
 }
 //if ""undecided/other" was checked, validate to make sure that the "other" value is not empty.
 if (isset($isOtherProgramGiven)) {
     wise_validate('wiseIntakeIntendedProgramOther', 'You must specify your "other" program!');
 }
 //if required fields are not empty and data is valid, add the data for this form to the session array,
 //then redirect user to either the previous or next page (since this is page 1, redirect only to page 2).
 if (empty($errorArray)) {
     $_SESSION['wiseIntakeLName'] = $wiseIntakeLName;
     $_SESSION['wiseIntakeStudentID'] = $wiseIntakeStudentID;
     $_SESSION['wiseIntakeFName'] = $wiseIntakeFName;
     $_SESSION['wiseIntakeCourse'] = $wiseIntakeCourse;
     //optional, only add to session if not empty
     if (!empty($wiseIntakeMInitial)) {
         $_SESSION['wiseIntakeMInitial'] = $wiseIntakeMInitial;
     }
     $_SESSION['wiseIntakeEduBackground'] = $wiseIntakeEduBackground;
     $_SESSION['wiseIntakeEduGoal'] = $wiseIntakeEduGoal;
     $_SESSION['wiseIntakeEduCurrentStatus'] = $wiseIntakeEduCurrentStatus;