PDA

View Full Version : Processing form objects


jimbo
11-18-2000, 11:48 PM
I have checkboxes that indicate how a person preferred to be contaced, like by Phone, Email, Postal Mail etc.[nbsp][nbsp]In Matt's Wright's FormMail, any form field you put in your form is processed and emailed.[nbsp][nbsp] In my form, I have those three choices, all called "Contact_By", each with their respective value that gets passed onto the script.

With FormMail, the resulting email will say this:

Contact By:[nbsp][nbsp]Phone, Email, Postal Mail - depending on which ones are checked.

I've programmed this in PHP to do the same basic thing - although it will only return one value, even with all three are checked.

My question is, how do I go about having the form group the three choices together?[nbsp][nbsp]Would I need to dump them into an array or something?

Any help would be very appreciated :).

-jim

Arthur
11-19-2000, 05:06 AM
Yes, you need to use an array;

<input type=&quot;checkbox&quot; name=&quot;Contact_By[]&quot; value=&quot;Phone&quot;> Phone
<input type=&quot;checkbox&quot; name=&quot;Contact_By[]&quot; value=&quot;Email&quot;> Email
<input type=&quot;checkbox&quot; name=&quot;Contact_By[]&quot; value=&quot;Postal Mail&quot;> Postal mail

and on the receiving page you could do something like;
<?php

for ($i=0; $i<sizeof($Contact_By); $i++) {
[nbsp][nbsp][nbsp][nbsp]echo $Contact_By[$i].&quot;
&quot;;
}

?>

HTH

---
Arthur

[This message has been edited by arthur (edited 11-19-00@05:03 am)]