Hi,
That's a nice form!
Checkboxes and radio buttons need to be handled differently and FormMail doesn't currently support them.
Another user of FormMail sent us some code which he uses to handle these and we'll be adding this feature in the next couple of weeks.
We'll also be adding support for HTML email, so you'll to get a nicely formatted form result in your email.
Ted sent the following code to us, but we haven't checked it out in detail.
The changes look simple, so you're welcome to try them:
Making a form with multiple value elements (checkboxes and multiple select menus):
PHP requires that you name such elements in your form in the following way, so that all selected values
get passed as to PHP as an array:
<input type="checkbox" name="events[]" value="Diving">Diving
<input type="checkbox" name="events[]" value="Cycling">Cycling
<select name="my_choices[]" multiple>
<option value="Red">Red
<option value="Blue">Blue
</select>
Note the [] at the end of each element name.
PHP Code:
The alteration to formmail.php is as follows:
function ParseInput($vars,&$a_values,$s_line_feed)
{
global $SPECIAL_FIELDS,$SPECIAL_VALUES,$FORMATTED_INPUT;
$output = "";
//
// scan the array of values passed in (name-value pairs) and
// produce slightly formatted (not HTML) textual output
//
while (list($name,$raw_value) = each($vars))
{
if (is_array($raw_value))
{
//
// handle checkbox input
//
while (list($checkbox_name,$checkbox_raw_value) = each($raw_value))
{
if (is_string($checkbox_raw_value))
{
//
// truncate the string
//
$checkbox_raw_value = substr($checkbox_raw_value,0,MAXSTRING);
}
$checkbox_value = trim(Strip($checkbox_raw_value));
$a_values[$checkbox_name] = $checkbox_raw_value;
$output .= "$name$checkbox_name: $checkbox_value".$s_line_feed;
array_push($FORMATTED_INPUT,"$name: '$value'");
}
}
elseif (is_string($raw_value))
{
//
// truncate the string
//
$raw_value = substr($raw_value,0,MAXSTRING);
}
$value = trim(Strip($raw_value));
if (in_array($name,$SPECIAL_FIELDS)) {
$SPECIAL_VALUES[$name] = $value;
}
else
{
if (! is_array($raw_value)) {
$a_values[$name] = $raw_value;
$output .= "$name: $value".$s_line_feed;
}
}
array_push($FORMATTED_INPUT,"$name: '$value'");
}
return ($output);
}
It looks like you can just replace FormMail's ParseInput function with the above and it will all work.
Good luck and please let us know if this works for you.
Bookmarks