Custom $error array not working

I am using the following code for a simple submission form. For some reason, when you don’t fill out a field, it should create an error in the error array, and then put that value in the input field’s value. I can’t figure out why it’s not working. Any suggestions?


<?php
	$title = 'Sign Up for a Ministry';
	$section = 'Ministries';
	$sidebar_calendar = 'all';
?>

<!DOCTYPE html>

<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/head.php"); ?>

</head>

<body>

<div class="wrap">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/nav.php"); ?>
	<section id="content">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/calendar.php"); ?>
		<article>
			<h2>Sign Up for a Ministry</h2>

			<?php
			
				if (isset($_POST['submit'])) {
				
					// Create error array
					$errors = array();
					$errors['first_name'] = '';
					$errors['last_name'] = '';
					$errors['address_1'] = '';
					$errors['city'] = '';
					$errors['state'] = '';
					$errors['zip_code'] = '';
					$errors['home_phone'] = '';
					$errors['email'] = '';
					
					// Gather and validate variables
					$first_name = '';
					$last_name = '';
					$address_1 = '';
					$address_2 = '';
					$city = '';
					$state = '';
					$zip_code = '';
					$home_phone = '';
					$email = '';
					$ministries = array();
					
					if (isset($_POST['first_name']) && $_POST['first_name'] !== '' && $_POST['first_name'] !== 'Required!') {
						$first_name = trim($_POST['first_name']);
					} else {
						$errors['first_name'] == 'Required!';
						$first_name = NULL;
					}
					
					if (isset($_POST['last_name']) && $_POST['last_name'] !== 'Required!') {
						$last_name = trim($_POST['last_name']);
					} else {
						$errors['last_name'] == 'Required!';
						$last_name = NULL;
					}
					
					if (isset($_POST['address_1']) && $_POST['address_1'] !== 'Required!') {
						$address_1 = trim($_POST['address_1']);
					} else {
						$errors['address_1'] == 'Required!';
						$address_1 = NULL;
					}
					
					if (isset($_POST['address_2'])) {
						$address_2 = trim($_POST['address_2']);
					} else {
						$address_2 = NULL;
					}
					
					if (isset($_POST['city']) && $_POST['city'] !== 'Required!') {
						$city = trim($_POST['city']);
					} else {
						$errors['city'] == 'Required!';
						$city = NULL;
					}
					
					if (isset($_POST['state']) && $_POST['state'] !== 'Choose State') {
						$state = $_POST['state'];
					} else {
						$errors['state'] == 'Required!';
						$state = NULL;
					}
					
					if (isset($_POST['zip_code']) && $_POST['zip_code'] !== 'Required!') {
						$zip_code = trim($_POST['zip_code']);
					} else {
						$errors['zip_code'] == 'Required!';
						$zip_code = NULL;
					}
					
					if (isset($_POST['home_phone']) && $_POST['home_phone'] !== 'Required!') {
						$home_phone = trim($_POST['home_phone']);
					} else {
						$errors['home_phone'] == 'Required!';
						$home_phone = NULL;
					}
					
					if (isset($_POST['email']) && ($_POST['email'] !== 'Required!' || $_POST['email'] !== 'Invalid email!')) {
						if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false) {
							$email = trim($_POST['email']);
						} else {
							$errors['email'] = 'Invalid email!';
						}
					} else {
						$errors['email'] == 'Required!';
						$email = NULL;
					}
					
					if (!empty($_POST['ministries'])) {			
						foreach ($_POST['ministries'] as $key => $value) {
							$ministries[] = $_POST['ministries'][$key];
						}
					} else {
						$errors['ministries'] = 'You must choose at least one ministry!';
						$ministries = NULL;
					}
					
					if (empty($errors)) {
					
						// Create email
						$message = "A member of <strong>St. William the Abbot</strong> parish would like some more information about the following ministries!\
\
";
						$message .= "<ul>\
";
						foreach ($ministries as $key => $value) {
							$message .= '<li>' . $value . "</li>\
";
						}
						$message .= "<strong>Name:</strong> $first_name $last_name\
";
						$message .= "<strong>Address:</strong>\
";
						$message .= "$address_1\
";
						$message .= "$address_2\
";
						$message .= "$city, $state $zip_code\
";
						$message .= "<strong>Home Phone:</strong> $home_phone\
";
						$message .= "<strong>Email:</strong> $email";
						
						// Add email headers
						$to = 'barry@jameswebdevelopment.com';
						$subject = "St. William Parishioner $first_name $last_name interested in ministries!";
						$headers = 'From: barry@jameswebdevelopment.com' . "\\r\
" .
							'Reply-To: ' . $email . "\\r\
" .
							'X-Mailer: PHP/' . phpversion();

						mail($to, $subject, $message, $headers);
						
						// Print thank you response
						echo '<p>Thank you!  A member of the parish staff will respond to your request shortly!</p>';
					
					} else {
					
						// Display error message
						echo '<h3 class="error">Whoops!</h3>';
						echo '<p class="error">Please correct the errors below and resubmit the form.</p>';
					
					}
				
				} else {
				
					echo '<p>Please fill out the form below to receive more information about the many ministries offered at St. William.</p>';
					
				}
			
			?>
			
			<form method="post" action="ministry-signup.php" id="ministry-signup">
				<fieldset>
				<legend>Personal Information</legend>
					<div>
						<div class="left">
							<div><label for="first_name">First Name:<br /><input type="text" name="first_name" id="first_name" tabindex="1" <?php if (isset($errors['first_name'])) {echo ' value="' . $errors['first_name'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="address_1">Address 1:<br /><input type="text" name="address_1" id="address_1" tabindex="3"<?php if (isset($errors['address_1'])) {echo ' value="' . $errors['address_1'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="city">City:<br /><input type="text" name="city" id="city" tabindex="5"<?php if (isset($errors['city'])) {echo ' value="' . $errors['city'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="zip_code">Zip Code:<br /><input type="text" name="zip_code" id="zip_code" tabindex="7"<?php if (isset($errors['zip_code'])) {echo ' value="' . $errors['zip_code'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="email">Email:<br /><input type="text" name="email" id="email" tabindex="9"<?php if (isset($errors['email'])) {echo ' value="' . $errors['email'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
						</div>
						<div class="left">
							<div><label for="last_name">Last Name:<br /><input type="text" name="last_name" id="last_name" tabindex="2"<?php if (isset($errors['last_name'])) {echo ' value="' . $errors['last_name'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="address_2">Address 2:<br /><input type="text" name="address_2" id="address_2" tabindex="4" /></label></div>
							<div><label for="state">State:<br />
								<select name="state" tabindex="6">
									<option value="Choose State"<?php if (isset($errors['state'])) {echo ' class="error" selected';} ?>>Choose State</option>
									<option value="AL">Alabama</option>
									<option value="AK">Alaska</option>
									<option value="AZ">Arizona</option>
									<option value="AR">Arkansas</option>
									<option value="CA">California</option>
									<option value="CO">Colorado</option>
									<option value="CT">Connecticut</option>
									<option value="DE">Delaware</option>
									<option value="DC">District of Columbia</option>
									<option value="FL">Florida</option>
									<option value="GA">Georgia</option>
									<option value="HI">Hawaii</option>
									<option value="ID">Idaho</option>
									<option value="IL">Illinois</option>
									<option value="IN">Indiana</option>
									<option value="IA">Iowa</option>
									<option value="KS">Kansas</option>
									<option value="KY">Kentucky</option>
									<option value="LA">Louisiana</option>
									<option value="ME">Maine</option>
									<option value="MD">Maryland</option>
									<option value="MA">Massachusetts</option>
									<option value="MI">Michigan</option>
									<option value="MN">Minnesota</option>
									<option value="MS">Mississippi</option>
									<option value="MO">Missouri</option>
									<option value="MT">Montana</option>
									<option value="NE">Nebraska</option>
									<option value="NV">Nevada</option>
									<option value="NH">New Hampshire</option>
									<option value="NJ">New Jersey</option>
									<option value="NM">New Mexico</option>
									<option value="NY">New York</option>
									<option value="NC">North Carolina</option>
									<option value="ND">North Dakota</option>
									<option value="OH">Ohio</option>
									<option value="OK">Oklahoma</option>
									<option value="OR">Oregon</option>
									<option value="PA">Pennsylvania</option>
									<option value="RI">Rhode Island</option>
									<option value="SC">South Carolina</option>
									<option value="SD">South Dakota</option>
									<option value="TN">Tennessee</option>
									<option value="TX">Texas</option>
									<option value="UT">Utah</option>
									<option value="VT">Vermont</option>
									<option value="VA">Virginia</option>
									<option value="WA">Washington</option>
									<option value="WV">West Virginia</option>
									<option value="WI">Wisconsin</option>
									<option value="WY">Wyoming</option>
								</select>
							</label></div>
							<div><label for="home_phone">Home Phone:<br /><input type="text" name="home_phone" id="home_phone" tabindex="8"<?php if (isset($errors['home_phone'])) {echo ' value="' . $errors['home_phone'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
						</div>
					</div>
				</fieldset>
				<?php if (isset($errors['ministries'])) {echo '<p class="error">' . $errors['ministries'] . '</p>';} ?>
				<fieldset>
				<legend>Ministries</legend>
					<p>Choose all of the ministries you are interested in.</p>
					<div>
						<div class="left">
							<h4>Liturgical Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="altar-guild" tabindex="10" /> Altar Guild</li>
								<li><input type="checkbox" name="ministries[]" value="altar-sevrers" tabindex="11" /> Altar Sevrers</li>
								<li><input type="checkbox" name="ministries[]" value="extraordinary-ministers-holy-communion" tabindex="12" /> Extraordinary Ministers of Holy Communion</li>
								<li><input type="checkbox" name="ministries[]" value="junior-lectors" tabindex="13" /> Junior Lectors</li>
								<li><input type="checkbox" name="ministries[]" value="lectors" tabindex="14" /> Lectors</li>
								<li><input type="checkbox" name="ministries[]" value="parish-liturgy-committee" tabindex="15" /> Parish Liturgy Committee</li>
								<li><input type="checkbox" name="ministries[]" value="ushers" tabindex="16" /> Ushers</li>
								<li><input type="checkbox" name="ministries[]" value="music" tabindex="17" /> Music Ministry</li>
							</ul>
							<h4>Sacramental Preparation</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="baptismal-preparation" tabindex="18" /> Baptismal Preparation Program</li>
								<li><input type="checkbox" name="ministries[]" value="confirmation-preparation" tabindex="19" /> Confirmation Preparation Program</li>
								<li><input type="checkbox" name="ministries[]" value="gift" tabindex="20" /> G.I.F.T. Program</li>
								<li><input type="checkbox" name="ministries[]" value="in-home-pre-cana" tabindex="21" /> In-Home Pre-Cana</li>
								<li><input type="checkbox" name="ministries[]" value="rcia" tabindex="22" /> Rite of Christian Initiation of Adults (RCIA)</li>
								<li><input type="checkbox" name="ministries[]" value="wedding-rehearsal" tabindex="23" /> Wedding Rehearsal Ministry</li>
							</ul>
							<h4>Education and Formation</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="saint-william-school" tabindex="24" /> St. William the Abbot School</li>
								<li><input type="checkbox" name="ministries[]" value="fun-with-god" tabindex="25" /> Fun with God</li>
								<li><input type="checkbox" name="ministries[]" value="home-school-association" tabindex="26" /> Home School Association</li>
								<li><input type="checkbox" name="ministries[]" value="religious-education" tabindex="27" /> Religious Education</li>
								<li><input type="checkbox" name="ministries[]" value="school-board" tabindex="28" /> School Board</li>
								<li><input type="checkbox" name="ministries[]" value="youth-ministry-high-school" tabindex="29" /> Youth Ministry/High School</li>
								<li><input type="checkbox" name="ministries[]" value="swa-teens" tabindex="30" /> SWA Teens</li>
							</ul>
						</div>
						<div class="left">
							<h4>Social Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="saint-vincent-de-paul" tabindex="31" /> St. Vincent de Paul Society</li>
								<li><input type="checkbox" name="ministries[]" value="abbot-innkeepers" tabindex="32" /> Abbot INNKEEPERS</li>
								<li><input type="checkbox" name="ministries[]" value="advocacy" tabindex="33" /> Advocacy</li>
								<li><input type="checkbox" name="ministries[]" value="shoppers" tabindex="34" /> Shoppers</li>
								<li><input type="checkbox" name="ministries[]" value="special-projects" tabindex="35" /> Special Projects</li>
								<li><input type="checkbox" name="ministries[]" value="transportation" tabindex="36" /> Transportation</li>
								<li><input type="checkbox" name="ministries[]" value="abbot-seniors" tabindex="37" /> The Abbot Seniors</li>
								<li><input type="checkbox" name="ministries[]" value="bereavement" tabindex="38" /> Bereavement</li>
								<li><input type="checkbox" name="ministries[]" value="consolation" tabindex="39" /> Consolation Ministry</li>
								<li><input type="checkbox" name="ministries[]" value="friendly-visitor" tabindex="40" /> Friendly Visitor</li>
								<li><input type="checkbox" name="ministries[]" value="moms-tots" tabindex="41" /> Moms and Tots</li>
							</ul>
							<h4>Spiritual Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="adult-antioch-community" tabindex="42" /> Adult Antioch Community</li>
								<li><input type="checkbox" name="ministries[]" value="nocturnal-adoration-society" tabindex="43" /> Nocturnal Adoration Society</li>
								<li><input type="checkbox" name="ministries[]" value="rosary-society" tabindex="44" /> Rosary Society</li>
								<li><input type="checkbox" name="ministries[]" value="small-christian-communities" tabindex="45" /> Small Christian Communities</li>
							</ul>
							<h4>General Parish Organizations</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="abbey" tabindex="46" /> The Abbey</li>
								<li><input type="checkbox" name="ministries[]" value="bingo" tabindex="47" /> Bingo</li>
								<li><input type="checkbox" name="ministries[]" value="blood-drive" tabindex="48" /> Blood Drive</li>
								<li><input type="checkbox" name="ministries[]" value="brownies-girl-scouts" tabindex="49" /> Brownies/Girl Scouts</li>
								<li><input type="checkbox" name="ministries[]" value="building-grounds-committee" tabindex="50" /> Building and Grounds Committee</li>
								<li><input type="checkbox" name="ministries[]" value="catholic-ministries-appeal-committee" tabindex="51" /> Catholic Ministries Appeal Committee</li>
								<li><input type="checkbox" name="ministries[]" value="cub-boy-scouts" tabindex="52" /> Cub/Boy Scouts</li>
								<li><input type="checkbox" name="ministries[]" value="cyo" tabindex="53" /> CYO</li>
								<li><input type="checkbox" name="ministries[]" value="family-festival" tabindex="54" /> Family Festival</li>
								<li><input type="checkbox" name="ministries[]" value="fathers-club" tabindex="55" /> Fathers’ Club</li>
								<li><input type="checkbox" name="ministries[]" value="finance-committee" tabindex="56" /> Finance Committee</li>
								<li><input type="checkbox" name="ministries[]" value="general-office-helpers" tabindex="57" /> General Office Helpers</li>
								<li><input type="checkbox" name="ministries[]" value="hospitality-ministry" tabindex="58" /> Hospitality Ministry</li>
								<li><input type="checkbox" name="ministries[]" value="human-life-committee" tabindex="59" /> Human Life Committee</li>
								<li><input type="checkbox" name="ministries[]" value="pastoral-council" tabindex="60" /> Pastoral Council</li>
								<li><input type="checkbox" name="ministries[]" value="stewardship-committee" tabindex="61" /> Stewardship Committee</li>
								<li><input type="checkbox" name="ministries[]" value="technology-committee" tabindex="62" /> Technology Committee</li>
								<li><input type="checkbox" name="ministries[]" value="welcoming-committee" tabindex="63" /> Welcoming Committee</li>
							</ul>
						</div>
					</div>
				</fieldset>
				<div><input type="submit" name="submit" id="submit" value="Submit" tabindex="64" /></div>
			</form>
		</article>
		<footer>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/topics-footer.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/mass-schedule-readings.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"); ?>
		</footer>
	</section>
</div>

</body>

</html>

This line:


$errors['first_name'] = ''; 

Sets the empty string to the array element that means the index ‘first_name’ is set. So the following will return try:


if(isset($errors['first_name'])){
  //....
}

So you need to use if not empty:


<input type="text" name="first_name" id="first_name" tabindex="1" <?php if (!empty($errors['first_name'])) {echo ' value="' . $errors['first_name'] . '" class="error"';} else {echo ' value=""';} ?> />

Though I haven’t tried it but should work.

Good luck!

That didn’t seem to work, so I also tried removing the first line you mentioned above and still couldn’t get it to work. Here is what I am left with:


<?php
	$title = 'Sign Up for a Ministry';
	$section = 'Ministries';
	$sidebar_calendar = 'all';
?>

<!DOCTYPE html>

<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/head.php"); ?>

</head>

<body>

<div class="wrap">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/nav.php"); ?>
	<section id="content">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/calendar.php"); ?>
		<article>
			<h2>Sign Up for a Ministry</h2>

			<?php
			
				if (isset($_POST['submit'])) {
				
					// Create error array
					$errors = array();
					
					// Gather and validate variables
					$first_name = '';
					$last_name = '';
					$address_1 = '';
					$address_2 = '';
					$city = '';
					$state = '';
					$zip_code = '';
					$home_phone = '';
					$email = '';
					$ministries = array();
					
					if (isset($_POST['first_name']) && $_POST['first_name'] !== '' && $_POST['first_name'] !== 'Required!') {
						$first_name = trim($_POST['first_name']);
					} else {
						$errors['first_name'] == 'Required!';
						$first_name = NULL;
					}
					
					if (isset($_POST['last_name']) && $_POST['last_name'] !== 'Required!') {
						$last_name = trim($_POST['last_name']);
					} else {
						$errors['last_name'] == 'Required!';
						$last_name = NULL;
					}
					
					if (isset($_POST['address_1']) && $_POST['address_1'] !== 'Required!') {
						$address_1 = trim($_POST['address_1']);
					} else {
						$errors['address_1'] == 'Required!';
						$address_1 = NULL;
					}
					
					if (isset($_POST['address_2'])) {
						$address_2 = trim($_POST['address_2']);
					} else {
						$address_2 = NULL;
					}
					
					if (isset($_POST['city']) && $_POST['city'] !== 'Required!') {
						$city = trim($_POST['city']);
					} else {
						$errors['city'] == 'Required!';
						$city = NULL;
					}
					
					if (isset($_POST['state']) && $_POST['state'] !== 'Choose State') {
						$state = $_POST['state'];
					} else {
						$errors['state'] == 'Required!';
						$state = NULL;
					}
					
					if (isset($_POST['zip_code']) && $_POST['zip_code'] !== 'Required!') {
						$zip_code = trim($_POST['zip_code']);
					} else {
						$errors['zip_code'] == 'Required!';
						$zip_code = NULL;
					}
					
					if (isset($_POST['home_phone']) && $_POST['home_phone'] !== 'Required!') {
						$home_phone = trim($_POST['home_phone']);
					} else {
						$errors['home_phone'] == 'Required!';
						$home_phone = NULL;
					}
					
					if (isset($_POST['email']) && ($_POST['email'] !== 'Required!' || $_POST['email'] !== 'Invalid email!')) {
						if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) !== false) {
							$email = trim($_POST['email']);
						} else {
							$errors['email'] = 'Invalid email!';
						}
					} else {
						$errors['email'] == 'Required!';
						$email = NULL;
					}
					
					if (!empty($_POST['ministries'])) {			
						foreach ($_POST['ministries'] as $key => $value) {
							$ministries[] = $_POST['ministries'][$key];
						}
					} else {
						$errors['ministries'] = 'You must choose at least one ministry!';
						$ministries = NULL;
					}
					
					if (empty($errors)) {
					
						// Create email
						$message = "A member of <strong>St. William the Abbot</strong> parish would like some more information about the following ministries!\
\
";
						$message .= "<ul>\
";
						foreach ($ministries as $key => $value) {
							$message .= '<li>' . $value . "</li>\
";
						}
						$message .= "<strong>Name:</strong> $first_name $last_name\
";
						$message .= "<strong>Address:</strong>\
";
						$message .= "$address_1\
";
						$message .= "$address_2\
";
						$message .= "$city, $state $zip_code\
";
						$message .= "<strong>Home Phone:</strong> $home_phone\
";
						$message .= "<strong>Email:</strong> $email";
						
						// Add email headers
						$to = 'barry@jameswebdevelopment.com';
						$subject = "St. William Parishioner $first_name $last_name interested in ministries!";
						$headers = 'From: barry@jameswebdevelopment.com' . "\\r\
" .
							'Reply-To: ' . $email . "\\r\
" .
							'X-Mailer: PHP/' . phpversion();

						mail($to, $subject, $message, $headers);
						
						// Print thank you response
						echo '<p>Thank you!  A member of the parish staff will respond to your request shortly!</p>';
					
					} else {
					
						// Display error message
						echo '<h3 class="error">Whoops!</h3>';
						echo '<p class="error">Please correct the errors below and resubmit the form.</p>';
					
					}
				
				} else {
				
					echo '<p>Please fill out the form below to receive more information about the many ministries offered at St. William.</p>';
					
				}
			
			?>
			
			<form method="post" action="ministry-signup.php" id="ministry-signup">
				<fieldset>
				<legend>Personal Information</legend>
					<div>
						<div class="left">
							<div><label for="first_name">First Name:<br /><input type="text" name="first_name" id="first_name" tabindex="1" <?php if (isset($errors['first_name'])) {echo ' value="' . $errors['first_name'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="address_1">Address 1:<br /><input type="text" name="address_1" id="address_1" tabindex="3"<?php if (isset($errors['address_1'])) {echo ' value="' . $errors['address_1'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="city">City:<br /><input type="text" name="city" id="city" tabindex="5"<?php if (isset($errors['city'])) {echo ' value="' . $errors['city'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="zip_code">Zip Code:<br /><input type="text" name="zip_code" id="zip_code" tabindex="7"<?php if (isset($errors['zip_code'])) {echo ' value="' . $errors['zip_code'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="email">Email:<br /><input type="text" name="email" id="email" tabindex="9"<?php if (isset($errors['email'])) {echo ' value="' . $errors['email'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
						</div>
						<div class="left">
							<div><label for="last_name">Last Name:<br /><input type="text" name="last_name" id="last_name" tabindex="2"<?php if (isset($errors['last_name'])) {echo ' value="' . $errors['last_name'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
							<div><label for="address_2">Address 2:<br /><input type="text" name="address_2" id="address_2" tabindex="4" /></label></div>
							<div><label for="state">State:<br />
								<select name="state" tabindex="6">
									<option value="Choose State"<?php if (isset($errors['state'])) {echo ' class="error" selected';} ?>>Choose State</option>
									<option value="AL">Alabama</option>
									<option value="AK">Alaska</option>
									<option value="AZ">Arizona</option>
									<option value="AR">Arkansas</option>
									<option value="CA">California</option>
									<option value="CO">Colorado</option>
									<option value="CT">Connecticut</option>
									<option value="DE">Delaware</option>
									<option value="DC">District of Columbia</option>
									<option value="FL">Florida</option>
									<option value="GA">Georgia</option>
									<option value="HI">Hawaii</option>
									<option value="ID">Idaho</option>
									<option value="IL">Illinois</option>
									<option value="IN">Indiana</option>
									<option value="IA">Iowa</option>
									<option value="KS">Kansas</option>
									<option value="KY">Kentucky</option>
									<option value="LA">Louisiana</option>
									<option value="ME">Maine</option>
									<option value="MD">Maryland</option>
									<option value="MA">Massachusetts</option>
									<option value="MI">Michigan</option>
									<option value="MN">Minnesota</option>
									<option value="MS">Mississippi</option>
									<option value="MO">Missouri</option>
									<option value="MT">Montana</option>
									<option value="NE">Nebraska</option>
									<option value="NV">Nevada</option>
									<option value="NH">New Hampshire</option>
									<option value="NJ">New Jersey</option>
									<option value="NM">New Mexico</option>
									<option value="NY">New York</option>
									<option value="NC">North Carolina</option>
									<option value="ND">North Dakota</option>
									<option value="OH">Ohio</option>
									<option value="OK">Oklahoma</option>
									<option value="OR">Oregon</option>
									<option value="PA">Pennsylvania</option>
									<option value="RI">Rhode Island</option>
									<option value="SC">South Carolina</option>
									<option value="SD">South Dakota</option>
									<option value="TN">Tennessee</option>
									<option value="TX">Texas</option>
									<option value="UT">Utah</option>
									<option value="VT">Vermont</option>
									<option value="VA">Virginia</option>
									<option value="WA">Washington</option>
									<option value="WV">West Virginia</option>
									<option value="WI">Wisconsin</option>
									<option value="WY">Wyoming</option>
								</select>
							</label></div>
							<div><label for="home_phone">Home Phone:<br /><input type="text" name="home_phone" id="home_phone" tabindex="8"<?php if (isset($errors['home_phone'])) {echo ' value="' . $errors['home_phone'] . '" class="error"';} else {echo ' value=""';} ?> /></label></div>
						</div>
					</div>
				</fieldset>
				<?php if (isset($errors['ministries'])) {echo '<p class="error">' . $errors['ministries'] . '</p>';} ?>
				<fieldset>
				<legend>Ministries</legend>
					<p>Choose all of the ministries you are interested in.</p>
					<div>
						<div class="left">
							<h4>Liturgical Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="altar-guild" tabindex="10" /> Altar Guild</li>
								<li><input type="checkbox" name="ministries[]" value="altar-sevrers" tabindex="11" /> Altar Sevrers</li>
								<li><input type="checkbox" name="ministries[]" value="extraordinary-ministers-holy-communion" tabindex="12" /> Extraordinary Ministers of Holy Communion</li>
								<li><input type="checkbox" name="ministries[]" value="junior-lectors" tabindex="13" /> Junior Lectors</li>
								<li><input type="checkbox" name="ministries[]" value="lectors" tabindex="14" /> Lectors</li>
								<li><input type="checkbox" name="ministries[]" value="parish-liturgy-committee" tabindex="15" /> Parish Liturgy Committee</li>
								<li><input type="checkbox" name="ministries[]" value="ushers" tabindex="16" /> Ushers</li>
								<li><input type="checkbox" name="ministries[]" value="music" tabindex="17" /> Music Ministry</li>
							</ul>
							<h4>Sacramental Preparation</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="baptismal-preparation" tabindex="18" /> Baptismal Preparation Program</li>
								<li><input type="checkbox" name="ministries[]" value="confirmation-preparation" tabindex="19" /> Confirmation Preparation Program</li>
								<li><input type="checkbox" name="ministries[]" value="gift" tabindex="20" /> G.I.F.T. Program</li>
								<li><input type="checkbox" name="ministries[]" value="in-home-pre-cana" tabindex="21" /> In-Home Pre-Cana</li>
								<li><input type="checkbox" name="ministries[]" value="rcia" tabindex="22" /> Rite of Christian Initiation of Adults (RCIA)</li>
								<li><input type="checkbox" name="ministries[]" value="wedding-rehearsal" tabindex="23" /> Wedding Rehearsal Ministry</li>
							</ul>
							<h4>Education and Formation</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="saint-william-school" tabindex="24" /> St. William the Abbot School</li>
								<li><input type="checkbox" name="ministries[]" value="fun-with-god" tabindex="25" /> Fun with God</li>
								<li><input type="checkbox" name="ministries[]" value="home-school-association" tabindex="26" /> Home School Association</li>
								<li><input type="checkbox" name="ministries[]" value="religious-education" tabindex="27" /> Religious Education</li>
								<li><input type="checkbox" name="ministries[]" value="school-board" tabindex="28" /> School Board</li>
								<li><input type="checkbox" name="ministries[]" value="youth-ministry-high-school" tabindex="29" /> Youth Ministry/High School</li>
								<li><input type="checkbox" name="ministries[]" value="swa-teens" tabindex="30" /> SWA Teens</li>
							</ul>
						</div>
						<div class="left">
							<h4>Social Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="saint-vincent-de-paul" tabindex="31" /> St. Vincent de Paul Society</li>
								<li><input type="checkbox" name="ministries[]" value="abbot-innkeepers" tabindex="32" /> Abbot INNKEEPERS</li>
								<li><input type="checkbox" name="ministries[]" value="advocacy" tabindex="33" /> Advocacy</li>
								<li><input type="checkbox" name="ministries[]" value="shoppers" tabindex="34" /> Shoppers</li>
								<li><input type="checkbox" name="ministries[]" value="special-projects" tabindex="35" /> Special Projects</li>
								<li><input type="checkbox" name="ministries[]" value="transportation" tabindex="36" /> Transportation</li>
								<li><input type="checkbox" name="ministries[]" value="abbot-seniors" tabindex="37" /> The Abbot Seniors</li>
								<li><input type="checkbox" name="ministries[]" value="bereavement" tabindex="38" /> Bereavement</li>
								<li><input type="checkbox" name="ministries[]" value="consolation" tabindex="39" /> Consolation Ministry</li>
								<li><input type="checkbox" name="ministries[]" value="friendly-visitor" tabindex="40" /> Friendly Visitor</li>
								<li><input type="checkbox" name="ministries[]" value="moms-tots" tabindex="41" /> Moms and Tots</li>
							</ul>
							<h4>Spiritual Ministries</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="adult-antioch-community" tabindex="42" /> Adult Antioch Community</li>
								<li><input type="checkbox" name="ministries[]" value="nocturnal-adoration-society" tabindex="43" /> Nocturnal Adoration Society</li>
								<li><input type="checkbox" name="ministries[]" value="rosary-society" tabindex="44" /> Rosary Society</li>
								<li><input type="checkbox" name="ministries[]" value="small-christian-communities" tabindex="45" /> Small Christian Communities</li>
							</ul>
							<h4>General Parish Organizations</h4>
							<ul>
								<li><input type="checkbox" name="ministries[]" value="abbey" tabindex="46" /> The Abbey</li>
								<li><input type="checkbox" name="ministries[]" value="bingo" tabindex="47" /> Bingo</li>
								<li><input type="checkbox" name="ministries[]" value="blood-drive" tabindex="48" /> Blood Drive</li>
								<li><input type="checkbox" name="ministries[]" value="brownies-girl-scouts" tabindex="49" /> Brownies/Girl Scouts</li>
								<li><input type="checkbox" name="ministries[]" value="building-grounds-committee" tabindex="50" /> Building and Grounds Committee</li>
								<li><input type="checkbox" name="ministries[]" value="catholic-ministries-appeal-committee" tabindex="51" /> Catholic Ministries Appeal Committee</li>
								<li><input type="checkbox" name="ministries[]" value="cub-boy-scouts" tabindex="52" /> Cub/Boy Scouts</li>
								<li><input type="checkbox" name="ministries[]" value="cyo" tabindex="53" /> CYO</li>
								<li><input type="checkbox" name="ministries[]" value="family-festival" tabindex="54" /> Family Festival</li>
								<li><input type="checkbox" name="ministries[]" value="fathers-club" tabindex="55" /> Fathers’ Club</li>
								<li><input type="checkbox" name="ministries[]" value="finance-committee" tabindex="56" /> Finance Committee</li>
								<li><input type="checkbox" name="ministries[]" value="general-office-helpers" tabindex="57" /> General Office Helpers</li>
								<li><input type="checkbox" name="ministries[]" value="hospitality-ministry" tabindex="58" /> Hospitality Ministry</li>
								<li><input type="checkbox" name="ministries[]" value="human-life-committee" tabindex="59" /> Human Life Committee</li>
								<li><input type="checkbox" name="ministries[]" value="pastoral-council" tabindex="60" /> Pastoral Council</li>
								<li><input type="checkbox" name="ministries[]" value="stewardship-committee" tabindex="61" /> Stewardship Committee</li>
								<li><input type="checkbox" name="ministries[]" value="technology-committee" tabindex="62" /> Technology Committee</li>
								<li><input type="checkbox" name="ministries[]" value="welcoming-committee" tabindex="63" /> Welcoming Committee</li>
							</ul>
						</div>
					</div>
				</fieldset>
				<div><input type="submit" name="submit" id="submit" value="Submit" tabindex="64" /></div>
			</form>
		</article>
		<footer>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/topics-footer.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/mass-schedule-readings.php"); ?>
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"); ?>
		</footer>
	</section>
</div>

</body>

</html>

Never mind, I had two errors:

  1. I had == signs where I should have had =
  2. I forgot to add " && $_POST[‘first_name’] !== ‘’ " to my if statements

So you mean that now you fixed the error?

Yes, thanks!