foreachループからメールコードを除外しようとしています。現時点では、メール成功メッセージが3回表示されます。さまざまな組み合わせを試しましたが、一度しか表示されません...?
何か案は..?ありがとう
if (isset($_POST['submit'])) {
$posted = $_POST;
$options = array('option-1' => __('Procedure: Suture Skin Wounds', 'appthemes'),
'option-2' => __('Procedure: Cat castration', 'appthemes'),
'option-3' => __('Procedure: Cat spay', 'appthemes')
);
foreach ($options as $option => $value) {
if ($posted[$option] == "selected") {
echo "<li class='error-list'>";
echo "Please select an answer for:" . " " . $value . " >
" . '<a href="' . get_permalink(30) . '">Back to form</a>';
echo "</li>";
}// if == "selected"
else/* if(isset($_POST['submit'])) */ {
$adminemail = get_option('admin_email');
$ToEmail = $adminemail;
$EmailSubject = 'Skills Assessment Form';
$mailheader = "From Leapfrog";
$mailheader .= "Reply-To: " . $_POST["email"] . "\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Form:Small Animal\n";
$MESSAGE_BODY = "Name: " . $_POST["canname"] . "\n\n";
$MESSAGE_BODY .= "\n\n" . "Procedure: " . "Suture Skin Wounds: " . $_POST["option-1"];
$MESSAGE_BODY .= "\n\n" . "Procedure: " . "Cat castration: " . $_POST["option-2"];
$MESSAGE_BODY .= "\n\n" . "Procedure: " . "Cat spay: " . $_POST["option-3"];
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die("Failure");
echo "Your skills assessment form has been Sent:" . " " .
'<a href="' . get_permalink(13) . '">Back to your Dashboard</a>';
//echo '<a href="'.get_permalink(13).'">Dashboard</a>';
}//else
}//foreach loop;
}//if isset