I have a simple form that I made, for an outgoing email. In it is a checkbox for a destination $location. The location checkboxes are grouped together and php is using the following to give it initial value:
$location = isset($location) ? $location: array(‘None selected’);
Afterward, I’m using:
$destination = implode(’,’$location)
in order to display a success message.
The code appears to work, as far as checking for input. However, upon success, the form replies “Your message has been sent to None selected”. So, to be clear, $location seems to not return a true value.
Below, I’ve include the code that I think is pertinent. Please help if you can:
[php]<?php //sql connect. sql not pertinent to this question;
//process email
//if missing, add to $missing
$missing = array();
//process variables
$location = isset($location) ? $location: array(‘None selected’);
if ($_POST && empty($_POST[‘location’])) {
$mailSent = false;
array_push($missing, $location);
echo “
PLEASE SELECT A LOCATION
”;}
$message = $_POST[‘message’];
if ($_POST && empty($_POST[‘message’])) {
$mailSent = false;
array_push($missing, $message);
echo “
THERE IS NO MESSAGE TO SEND.
”;}
$destination = implode(’,’,$location);
//send it
if ($_POST && empty($missing)) {
$mailSent = mail($to, $subject, $message, $additionalHeaders);
}
}
?>
Mailing List
<?php if ($_POST && $mailSent) { echo "Your message has been sent to $destination.
"; unset($missing); } ?> SEND TO:checked = "checked" <?php } ?>/> Austin Area
checked = "checked" <?php } ?> /> DFW Area [/php]