Hi I've got a email form that uses array and a switch call to send values in a form to my email. The problem I'm having is I have a checkbox where users should be able to select multiple values however if they do when I receive the email instead of having the values it prints "ARRAY"...I've included a sample below:
<?
// Key => (required, type, string)
// Types:
// 1 - Long text
// 2 - Short text
// 3 - Textarea
// 4 - Radio
// 5 - Checkbox
// 6 - Dropdown
// 4, 5, and 6 require a 4th value in the array
$mail_form_to = "me@email.com";
$mail_form_subject = "Real Estate Submission";
$values = array(
"present" => array(1, 5, "If land property, please indicate which of the following are present:",
array("Access to land via road","road","water"))
);
if ($_POST["submitform"] != "") {
$errors = array();
$areerrors = 0;
foreach($values as $key => $value) {
if ($value[0] == 1 && $$key == "") {
$errors[$key] = 1;
$areerrors = 1;
}
}
if (!$areerrors) {
$count = 0;
foreach($values as $key => $value) {
$$key = stripslashes($$key);
$count++;
$email_body .= $count . ") " . $value[2] . "\n";
$email_body .= "- " . $$key . "\n\n";
}
mail($mail_form_to, $mail_form_subject, $email_body, "From: Test <noreply@email.com>"); header("Location: good.php");
exit();
} else {
foreach($_POST as $key => $value) {
if (!is_numeric($key)) $$key = htmlentities(stripslashes($value));
}
}
}
?>
///switch statment below
<?
$count = 0;
foreach($values as $key => $value) {
$count++;
?>
<p align="left">
<? if ($errors[$key] == 1) echo "<font color=red>";?>
<?=$count?>
.
<?=$value[2]?>
<? if ($value[0] == 1) echo "*"; ?>
<? if ($errors[$key] == 1) echo "</font>";?>
<br />
<?
switch ($value[1]) {
case "5": foreach($value[3] as $key2 => $value2) {
echo "<input name=\"$key"."[]\" type=\"checkbox\" value=\"".htmlentities($value2)."\"";
if (is_array($$key) && in_array($value2, $$key)) echo " CHECKED";
echo "> $value2 ".$$key."<br>";
} break;
default: echo "OTHER ITEM TYPE: $value[2]"; break;
}
?>
Any suggestions on having the checkbox submit the individual values accordingly instead of outputting "Array"?