bradgrafelman;10998067 wrote:Add square brackets '[]' onto the end of the field names (e.g. you'd end up with names like 'foo[]' rather than just 'foo'). This will cause PHP to aggregate all POST'ed items with that name into a single variable - $_POST['foo'] - as an array.
Ok apparently I am still doing something wrong as the variable does not get passed to the email array.
Here is what I did in the html code
<tr>
<td style="width: 124px" class="style15">Tape Recorder<?php if(isset($problems['tape'])) {?> <font color="red">*</font><?php } ?></td>
<td class="style9">
<input name="tape[]" type="checkbox" value="used before," <?php if(isset($_POST['tape'])) echo "checked"; ?>><span class="style15">
</span>
</td>
<td class="style9">
<input name="tape[]" type="checkbox" class="style15" value="helpful in past," <?php if(isset($_POST['tape'])) echo "checked"; ?>> <span class="style15">
</span>
<td class="style9">
<input name="tape[]" class="style15" type="checkbox" value="requesting from DACC" <?php if(isset($_POST['tape'])) echo "checked"; ?>><span class="style15">
</span>
<td class="style9">
<input name="tape[]" type="checkbox" value="NA" class="style15"<?php if(isset($_POST['tape'])) echo "checked"; ?>><span class="style15">
</span>
</tr>
then I went up to the PHP email information and I tried it with and without brackets in each spot.
<?php
$problems = array();
$showform = 0;
$errorMessage = "";
function validate($field, $value) {
// || $field == "id" || $field == "phone" || $field == "course" || $field == "instructor"
/*if ($field == "name" || $field == "email" || $field == "computers" || $field == "info") {*/
if ($value == "") {
return 0;
} else {
return 1;
}
/*}*/
/*if ($field == "system" || $field == "browser" || $field == "issue" || $field == "multiple") {
if ($value == "----" || $value == "") {
return 0;
} else {
return 1;
}
}*/
}
if($_POST) {
//'id','phone','course','instructor',
$fields = array('date','name', 'sid', 'bdate', 'saddress', 'city', 'state', 'zip', 'email', 'condition', 'classes', 'assignments', 'communication', 'evaluation', 'timeconstraints', 'attendance', 'campus', 'cocurricular', 'tape[]', 'note', 'device', 'signl', 'caption', 'tcalculator', 'enlarger', 'braille', 'dragon', 'other', 'extend', 'environment', 'processor', 'spell', 'calculator', 'reader', 'waiver', 'reduced', 'oaccommodation', 'affirm', 'filled');
$x = 0 - 1;
foreach($fields as $field) {
if(isset($_POST[$field])) {
$validation = validate($field, $_POST[$field]);
if ($validation == 1) {
$x++;
$info[$x] = $_POST[$field];
} else {
$problems[$field] = 1;
$showform = 1;
}
} else {
$problems[$field] = 1;
$showform = 1;
}
}
} else {
$showform = 1;
}
if(count($problems) < 1 && $_POST) {
// DO THE MAILING HERE
$fields = array('date', 'name', 'sid', 'bdate', 'saddress', 'city', 'state', 'zip', 'cell', 'alternate', 'email', 'condition', 'classes', 'assignments', 'communication', 'evaluation', 'timeconstraints', 'attendance', 'campus', 'cocurricular', 'accommodationsused', 'tape[]', 'note', 'device', 'signl', 'caption', 'tcalculator', 'enlarger', 'braille', 'dragon', 'other', 'otherspecify', 'extend', 'environment', 'processor', 'spell', 'calculator', 'reader', 'waiver', 'reduced', 'oaccommodation', 'affirm', 'filled', 'parentname', 'fillother');
//$to = "mhoover@dacc.edu";
$to2 = "aabdelzaher@dacc.edu";
//$to3 ="voliver@dacc.edu";
$subject = "Request for Accommodations";
$headers ='MIME-Version: 1.0' .PHP_EOL;
$headers .='Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers .= "From: noreply@dacc.edu\r\n" . "X-Mailer: php";
$greet = "The following was submitted on " . date("F j, Y, g:i a") . "<p><p>";
$body = $greet ;
$cn = 1;
foreach($fields as $efield) {
if(isset($_POST[$efield])) {
if($efield == "date") {
$body.= "<strong>". " Today's date: "."</strong> " . $_POST[$efield] ."<p>";
} elseif($efield == "tape[]" ) {
$body.= "<em>For Class Notes:</em><p><strong>". "Tape recorder: "."</strong> " . $_POST[$efield] .",<p>";
the form submits but then in the email this field just does not even show up.