//redundancy and reduce the number of if empty/else statements here. if a radio/checkbox //is empty, then that radio/checkbox's variable will contain an empty string. $wiseIntakeDemoGender = wise_check_radio_data('wiseIntakeDemoGender'); $wiseIntakeDemoDateOfBirth = $_POST['wiseIntakeDemoDateOfBirth']; //string $wiseIntakeDemoPrimaryPhoneNumber = $_POST['wiseIntakeDemoPrimaryPhoneNumber']; //string $wiseIntakeDemoPreferredEmail = $_POST['wiseIntakeDemoPreferredEmail']; //string $wiseIntakeDemoRace = wise_check_radio_data('wiseIntakeDemoRace'); $wiseIntakeDemoDisability = wise_check_radio_data('wiseIntakeDemoDisability'); $wiseIntakeDemoPellGrant = wise_check_radio_data('wiseIntakeDemoPellGrant'); $wiseIntakeDemoTAA = wise_check_radio_data('wiseIntakeDemoTAA'); $wiseIntakeDemoEligibleVeteran = wise_check_radio_data('wiseIntakeDemoEligibleVeteran'); $wiseIntakeDemoSpouseOfEligibleVeteran = wise_check_radio_data('wiseIntakeDemoSpouseOfEligibleVeteran'); $wiseIntakeEmploymentStatus = wise_check_radio_data('wiseIntakeEmploymentStatus'); $wiseIntakeEmployerName = $_POST['wiseIntakeEmployerName']; //optional string $wiseIntakeEmploymentStartDate = $_POST['wiseIntakeEmploymentStartDate']; //optional string $wiseIntakeEmploymentHoursPerWeek = $_POST['wiseIntakeEmploymentHoursPerWeek']; //optional string $wiseIntakeEmploymentCurrentSalary = $_POST['wiseIntakeEmploymentCurrentSalary']; //optional string //as a checkbox, this element's variable will be assigned and checked for emptiness without a function. if (!empty($_POST['verifyQuestionnaire'])) { $verifyQuestionnaire = $_POST['verifyQuestionnaire']; } else { $errorArray['verifyQuestionnaire'] = '<span class="form-error">You must verify the information to continue!</span>'; $verifyQuestionnaire = array(); }
//data is assumed valid unless an error is present in the $errorArray $errorArray = array(); //assign data to variables. note that if session variables were assigned before for form stickyness, //these POST results will be printed in the form instead of the session variables. $wiseIntakeLName = $_POST['wiseIntakeLName']; $wiseIntakeStudentID = $_POST['wiseIntakeStudentID']; $wiseIntakeFName = $_POST['wiseIntakeFName']; $wiseIntakeCourse = $_POST['wiseIntakeCourse']; $wiseIntakeMInitial = $_POST['wiseIntakeMInitial']; //optional //radio and checkboxes are retrieved with a check function; simply used to reduce code //redundancy and reduce the number of if empty/else statements here. if a radio/checkbox //is empty, then that radio/checkbox's variable will contain an empty string. $wiseIntakeEduBackground = wise_check_radio_data('wiseIntakeEduBackground'); $wiseIntakeEduGoal = wise_check_radio_data('wiseIntakeEduGoal'); $wiseIntakeEduCurrentStatus = wise_check_radio_data('wiseIntakeEduCurrentStatus'); //since the intended programs item is the only checkbox item in this entire form, //no function was created for its validation. //if no intended program was chosen, send an error message and set the variable to an empty array. //otherwise, assign the array to a variable. if (empty($_POST['wiseIntakeIntendedPrograms'])) { $errorArray['wiseIntakeIntendedPrograms'] = '<span class="form-error">You must choose at least one Intended Program!</span>'; $wiseIntakeIntendedPrograms = array(); } else { $wiseIntakeIntendedPrograms = $_POST['wiseIntakeIntendedPrograms']; //check if the "undecided/other" box was checked foreach ($wiseIntakeIntendedPrograms as $checkProgramForOther) { //if "undecided/other" was checked, get the value that the user assigned. if (array_search($checkProgramForOther, $intendedProgramsCheckboxes) == $intendedProgramsOtherOptionNumber) { $wiseIntakeIntendedProgramOther = $_POST['wiseIntakeIntendedProgramOther']; $isOtherProgramGiven = true;