Multiple Selections in E-mail?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rewt
Forum Newbie
Posts: 3
Joined: Tue Nov 04, 2003 7:18 am

Multiple Selections in E-mail?

Post by Rewt »

Here's the issue:
I've got a form that has multiple selections, and I need them to end up being emailed.

Right now, here's what I have:

Code: Select all

<form method="POST" action="<? echo"$PHP_SELF";?>">
<select size="4" name="selections&#1111;]" multiple>
 <option>Red</option>
 <option>Orange</option>
 <option>Yellow</option>
 <option>Green</option>
</select>
Now, when it's processed, it emails fine, however, all I get is 1 value for selections, regardless of how many are selected.

Any ideas?

Thanks in advance!
Rewt
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

in emailing page, you need to have a loop in the code which reads all the values from the selections array.

here is a sample.

Code: Select all

<?php
for($x = 0; $x<=count($selections); $x++)
{
if(!empty($selections[$x]))
{
$values .= $selections[$x]."\n";
}
}
?>
Rewt
Forum Newbie
Posts: 3
Joined: Tue Nov 04, 2003 7:18 am

So how would that end up in the mail() ?

Post by Rewt »

I see the stepping thru the array, and fully understand that.

However, how do I then plug that into the mail function?

Code: Select all

mail("user@email.com", "Web Form Submisison",
"selections&#1111;]", "From:$email");
Thanks for your help thus far... if I can just get it the rest of the way, I'll be set!
Rewt
Forum Newbie
Posts: 3
Joined: Tue Nov 04, 2003 7:18 am

Lightbulb.

Post by Rewt »

Umm. Yeah.

So, instead of $selections[], I just put $values in.

Ahem.

Thank you.
Post Reply