OK. Here are the implode function codes for starters. All processing code is included:
$mailSent = false;
if (array_key_exists('dogApp', $_POST)) {
// mail processing script
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}
$plansfordog = isset($plansfordog) ? $plansfordog : array('None selected');
$plansfordogOther = trim($_POST['plansfordogOther']);
if (isset($_POST['plansfordog']) && $_POST['plansfordog'] == 'Other:' && empty($plansfordogOther)) {
$error['plansfordogOther'] = 'Please explain what your plans are for the dog(s)';
}
$effectivetraining = isset($effectivetraining) ? $effectivetraining : array('None Selected');
$bathroomtraining = isset($bathroomtraining) ? $bathroomtraining : array('None Selected');
if (!isset($error)) {
$mailSent = mail($to, $subject, $message, $additionalHeaders);
// check that the mail was sent successfully
if (!$mailSent) {
$error['notSent'] = 'We\\'re sorry, there was a problem sending your mail. Please make another attempt to send your inquiry again. If this problem continues, please contact the webmaster at <a href=\\"mailto:webmaster@s.org\\">webmaster@s.org</a> for further assistance.';
}
}
Building of the message:
$message .= " 2. What are your plans for this dog? \\r\
";
$message .= implode(', ', $_POST['plansfordog']);
$message .= " 4. What do you believe to be the most effective training methods to train dogs? \\r\
";
$message .= implode(', ', $_POST['effectivetraining']);
$message .= "\\r\
\\r\
5. If this dog(s) is not housetrained, how will you train him or her to not go to the bathroom in the house? \\r\
";
$message .= implode(', ', $_POST['bathroomtraining']);
HTML: I’ve excluded some <td> tags to minimize space
<?php if (isset($error['notSent'])) { ?>
<h1>Server Error</h1>
<p class="warning"><?php echo $error['notSent']; ?></p>
<?php } elseif ($mailSent) { ?>
<h1>Thank you for your Application.</h1>
<p style="text-indent: 0px;">Thank you for taking the time to complete our adoption application. A representative with Noah’s will contact you in the next day or so.</p>
<p style="text-indent: 0px;">If you have any questions about your submitted application, please feel free to contact Kendra at 559-393-5146. Thanks for adopting!</p>
<?php } else { ?>
<h1>Dog Application & Agreement </h1>
<h2> Are you ready to adopt? </h2>
<p style="text-indent: 0px;">Please fill out the form below to apply to adopt a dog from Noah and Friends.</p>
<p class="warning">** All fields are required. ** </p>
<?php } ?>
<?php if (!$mailSent) { ?>
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" name="dogApp" id="dogApp">
<label for="plansfordog">2. What are your plans for this dog? (Please Check All That Apply):</label> <?php if (isset($error['plansfordogOther'])) { ?>
<span class="warning"><?php echo $error['plansfordogOther']; ?></span>
<?php } ?>
<br />
<input type="checkbox" name="plansfordog[]" value="Member of the family" id="familymember" <?php
$OK = isset($_POST['plansfordog']) ? true : false;
if ($OK && isset($error) && in_array('Member of the Family', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="familymember">Member of the family</label><br />
<input type="checkbox" name="plansfordog[]" value="Pet" id="pet" <?php
if ($OK && isset($error) && in_array('Pet', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="pet">Pet</label><br />
<input type="checkbox" name="plansfordog[]" value="Best Friend" id="bestfriend" <?php
if ($OK && isset($error) && in_array('Best Friend', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="bestfriend">Best Friend</label><br />
<input type="checkbox" name="plansfordog[]" value="Guard Dog" id="guarddog" <?php
if ($OK && isset($error) && in_array('Guard Dog', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="guarddog">Guard dog</label><br />
<input type="checkbox" name="plansfordog[]" value="Herding Dog" id="herdingdog" <?php
if ($OK && isset($error) && in_array('Herding Dog', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="herdingdog">Herding Dog</label><br />
<input type="checkbox" name="plansfordog[]" value="Obedience/Agility" id="obedience" <?php
if ($OK && isset($error) && in_array('Obedience/Agility', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="obedience">Obedience/Agility</label><br />
<input type="checkbox" name="plansfordog[]" value="Therapy Dog" id="therapy" <?php
if ($OK && isset($error) && in_array('Therapy Dog', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="therapy">Therapy dog</label><br />
<input type="checkbox" name="plansfordog[]" value="Hunting Dog" id="hunting" <?php
if ($OK && isset($error) && in_array('Hunting Dog', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="hunting">Hunting dog</label><br />
<input type="checkbox" name="plansfordog[]" value="Other:" id="plansfordog" <?php
if ($OK && isset($error) && in_array('Other:', $_POST['plansfordog'])) { ?> checked="checked"
<?php } ?> />
<label for="plansfordog">Other, please explain:</label>
<br />
<textarea name="plansfordogOther" cols="30" rows="5" id="plansfordogOther"><?php if (isset($_POST['plansfordogOther'])) {echo $_POST['plansfordogOther'];} ?></textarea>
<label for="effectivetraining">4. What do you believe to be the most effective training methods to train dogs? (Please Check All That Apply):</label><?php if (isset($error['effectivetraining'])) { ?>
<span class="warning"><?php echo $error['effectivetraining']; ?></span>
<?php } ?>
<br />
<input type="checkbox" name="effectivetraining[]" value="Food Treats" id="foodtreats" <?php
$OK = isset($_POST['effectivetraining']) ? true : false;
if ($OK && isset($error) && in_array('Food Treats', $_POST['effectivetraining'])) { ?> checked="checked"
<?php } ?> />
<label for="foodtreats">Food Treats</label>
<br />
<input type="checkbox" name="effectivetraining[]" value="Praise" id="praise" <?php
if ($OK && isset($error) && in_array('Praise', $_POST['effectivetraining'])) { ?> checked="checked"
<?php } ?> />
<label for="praise">Praise</label>
<br />
<input type="checkbox" name="effectivetraining[]" value="Physical punishment on certain occasions" id="punishment" <?php
if ($OK && isset($error) && in_array('Physical punishment on certain occasions', $_POST['effectivetraining'])) { ?> checked="checked"
<?php } ?> />
<label for="punishment">Physical punishment on certain occasions</label>
<br />
<input type="checkbox" name="effectivetraining[]" value="Obedience School" id="obedience" <?php
if ($OK && isset($error) && in_array('Obedience School', $_POST['effectivetraining'])) { ?> checked="checked"
<?php } ?> />
<label for="obedience">Obedience School</label><br />
<input type="checkbox" name="effectivetraining[]" value="Positive reinforcement for the behavior you want" id="reinforcement" <?php
if ($OK && isset($error) && in_array('Positive reinforcement for the behavior you want', $_POST['effectivetraining'])) { ?> checked="checked"
<?php } ?> />
<label for="reinforcement">Positive reinforcement for the behavior you want</label>
<label for="bathroomtraining">5. If this dog(s) is not housetrained, how will you train him or her to not go to the bathroom in the house? (Please Check All That Apply):</label><?php if (isset($error['bathroomtraining'])) { ?>
<span class="warning"><?php echo $error['bathroomtraining']; ?></span>
<?php } ?>
<br />
<input type="checkbox" name="bathroomtraining[]" value="Crate training" id="crate" <?php
$OK = isset($_POST['bathroomtraining']) ? true : false;
if ($OK && isset($error) && in_array('Crate training', $_POST['bathroomtraining'])) { ?> checked="checked"
<?php } ?> />
<label for="crate">Crate training</label>
<br />
<input type="checkbox" name="bathroomtraining[]" value="Carefully watching and anticipating his/her need to go to the bathroom and sending him/her outside and praising when he/she goes to the bathroom" id="carefulwatching" <?php
if ($OK && isset($error) && in_array('Carefully watching and anticipating his/her need to go to the bathroom and sending him/her outside and praising when he/she goes to the bathroom', $_POST['bathroomtraining'])) { ?> checked="checked"
<?php } ?> />
<label for="carefulwatching">Carefully watching and anticipating his/her need to go to the bathroom and sending him/her outside and praising when he/she goes to the bathroom</label><br />
<input type="checkbox" name="bathroomtraining[]" value="Rubbing his/her nose in its "mess" and then sending him/her promptly outside" id="rubbingnose" <?php
if ($OK && isset($error) && in_array('Rubbing his/her nose in its "mess" and then sending him/her promptly outside', $_POST['bathroomtraining'])) { ?> checked="checked"
<?php } ?> />
<label for="rubbingnose">Rubbing his/her nose in its "mess" and then sending him/her promptly outside</label>
<br />
<input type="checkbox" name="bathroomtraining[]" value="I have no idea, but I'd like some information on the subject" id="noidea" <?php
if ($OK && isset($error) && in_array('I have no idea, but I\\'d like some information on the subject', $_POST['bathroomtraining'])) { ?> checked="checked"
<?php } ?> />
<label for="noidea">I have no idea, but I'd like some information on the subject</label>
<input name="dogApp" type="submit" id="dogApp" tabindex="4" value="Send" />
</form><?php } ?>
I appreciate your time in looking at this for me. I know I’ve grown a little ‘burned-out’.