PDA

View Full Version : multiple check boxes


Red Blaze
12-15-2005, 07:19 PM
I know how to work with regular forms. Even drop downs. But not when it comes to multiple selections.

In my case, I have 8 check boxes with the name "sizes[]" with different values. When a user checks 1 or more boxes, I want that information to pass on to the next page to get sent in an email. Here's the block of coding I'm using.


<?php

$email = $_SESSION['MM_UserEmail'];
$username = $_SESSION['MM_Username'];
$userid = $_SESSION['MM_UserID'];
$instructions = $_POST['instructions'];

for ($x = 0; $x < count($sizes); $x++)
{
$papersize = "$sizes[$x]";
}

$message = "$username (userid $userid) wants \"$paper paper\" and the following sizes:\n\n
$papersize
has sent the following instructions:\n\n\"$instructions\".";
$from = $email;
$to = "some@email.com";
$subject = "$username (userid $userid) Uploaded Photographs";
$headers = "From: $from";

mail($to,$subject,$message,$headers);

$paper is the name of a drop down form with different papers.
$sizes is the name of the 8 check boxes with different sizes.


for ($x = 0; $x < count($sizes); $x++)
{
$papersize = "$sizes[$x]";
}

This peice of code is where I believe the problem lies. I tested it, and checked 3 sizes. However, only the last one is called out in the email. What am I doing wrong? I tried many ways, but no luck. Thanks for the help.

Andrew, I tried putting $papersize = "$sizes . $x"; but that didn't work. :p

I ran into this code which looked simpler but didn't work either.


foreach($sizes as $value)
{
$papersize = "$value ";
}