Hello,
I am using a Perl script to process and send form input to an e-mail address.
It works nicely when only one selection can be made, but one of my fields ("Stores[]") requires that the respondant make 3 selections. What happens is the processor only sends out the 1st field it encounters and ignores the following two.
The php form I was using handled it fine. However the IT guys can't figure out how to install/configure php on the Windows server(!) and so here I am trying to come up with another solution (I am the web designer).
Here is a snippet of the HTML code. The multiple-selects are named "Stores[]"
Here is a snippet of the Perl Script where I specify variables:
Here is the part of the code that actually processes the input, and I am
sure, where the solution lies:
(I have specified NO required fields, since I already have a javascript that is doing that)
Can anyone see an easy fix for this?
Also, if I am not pressing my luck, is there a simple way to have this processor ALSO write the form input to a comma-delimited file?
If not, no biggie on that one.
Thanks for all who respond
Rick
I am using a Perl script to process and send form input to an e-mail address.
It works nicely when only one selection can be made, but one of my fields ("Stores[]") requires that the respondant make 3 selections. What happens is the processor only sends out the 1st field it encounters and ignores the following two.
The php form I was using handled it fine. However the IT guys can't figure out how to install/configure php on the Windows server(!) and so here I am trying to come up with another solution (I am the web designer).
Here is a snippet of the HTML code. The multiple-selects are named "Stores[]"
Code:
<td>
<input type="checkbox" name="Stores[]" value="Gilroy" tabindex="11" />
</td>
<td>
<span style="white-space:nowrap;">Gilroy Store<br />
845 First Street<br />
Gilroy
</span>
</td>
<td>
<input type='checkbox' name='Stores[]' value='Santa_Teresa' style="float:left;" tabindex="15" />
</td>
<td>
<span style="white-space:nowrap;">Santa Teresa Store <br />
7098 Santa Teresa Blvd.<br />
San Jose</span>
</td>
<td>
<input type='checkbox' name='Stores[]' value='San_Carlos' style="float:left;" tabindex="19" />
</td>
<td>
<span style="white-space:nowrap;">San Carlos Store<br />
1691 W. San Carlos St.<br />
San Jose
</span>
</td>
etc...
Code:
#Order in which fields should be shown in the email - list all fields here - this is CASE SENSITIVE
@field_order = ("FirstName","LastName","Email","Gender","Income","Age","Language","Stores[]");
#You can check required fields at the form using Javascript, or list them here for simple checking.
#@required_fields = ("NAME","EMAIL","PHONE");
#Fields output - These give human readable labels to the output fields. Again, there should be one for each field.
$fields{"FirstName"} = "First Name";
$fields{"LastName"} = "Last Name";
$fields{"Email"} = "E-Mail Address";
$fields{"Gender"} = "Gender";
$fields{"Income"} = "Income Range";
$fields{"Age"} = "Age Range";
$fields{"Language"} = "Primary Language";
$fields{"Stores[]"} = "Favorite Stores";
sure, where the solution lies:
(I have specified NO required fields, since I already have a javascript that is doing that)
Code:
print $query->header;
#Check required Fields
my $field;
foreach $field (@required_fields) {
if(!$query->param($field)) {
print "<script>
alert(\"Please supply the following information: $fields{$field}\");
history.back();</script>";
exit;
}
}
#Send out the email
$smtp = Net::SMTP->new($mailhost);
$smtp->mail($ENV{USER});
foreach $r (@mail_to) {
$smtp->to($r);
}
$smtp->data();
$smtp->datasend("From: $mail_from\n");
$smtp->datasend("To: ".join(",",@mail_to)."\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("The following was submitted:\n\n");
my $outline;
foreach $f (@field_order) {
$outline = sprintf("%30s: %s",$fields{$f},$query->param($f));
$smtp->datasend($outline."\n");
}
$smtp->dataend();
$smtp->quit;
#Send out a Confirmation email
if($confirmation_email_to =~ /\@/) {
my $smtp = Net::SMTP->new($mailhost);
$smtp->mail($ENV{USER});
$smtp->to("$confirmation_email_to");
$smtp->data();
$smtp->datasend("From: $confirmation_email_from\n");
$smtp->datasend("To: $confirmation_email_to\n");
$smtp->datasend("Subject: $confirmation_subject\n");
$smtp->datasend("\n");
$smtp->datasend("$confirmation_body\n");
$smtp->dataend();
$smtp->quit;
}
print "<META HTTP-EQUIV=refresh content=\"0;URL=$thankyou_url\">\n";
Also, if I am not pressing my luck, is there a simple way to have this processor ALSO write the form input to a comma-delimited file?
If not, no biggie on that one.
Thanks for all who respond
Rick