ipaulo
Joined: 25 Jul 2005 Posts: 1
|
Posted: Mon Jul 25, 2005 6:53 pm Post subject: re: Processing multiple choice form |
|
|
I wanted to do the same thing. I'm not much of a programmer, so I'm sure this is going to be really ugly but it works. It also includes a line to skip blank fields. Look for this code:
| Code: | foreach($_POST as $k => $v) {
if($htmlFormat) {
$v = str_replace("\n","<br>\n",$v);
}
if($i) {
$msg .= "$bl0$k:$ld$v$el";
} else {
$msg .= "$bl1$k:$ld$v$el";
}
$i = !$i;
} |
replace it with this:
| Code: | foreach($_POST as $k => $v) {
if ($v == '') continue; // skip empty fields
if($htmlFormat) {
$v = str_replace("\n","<br>\n",$v);
}
if (is_array($v)) {
for ($z=0;$z<count($v);$z++) {
if($i) {
$msg .= "$bl0$k:$ld$v[$z]$el";
} else {
$msg .= "$bl1$k:$ld$v[$z]$el";
}
$i = !$i;
}
} else {
if($i) {
$msg .= "$bl0$k:$ld$v$el";
} else {
$msg .= "$bl1$k:$ld$v$el";
}
$i = !$i;
}
} |
|
|