Sending a form via php, checkboxes return "array" not intended value

Hello everyone, this is my first time with PHP so any help would be appreciated! I’ve been wracking my brain for two days now so I’m hoping this is an easy question for someone.

I have an HTML form which I am sending via PHP to my email address. Everything comes through except the checkedboxes. When they come into my inbox if one or more are checked it returns “array” instead of the value I have assigned it. I’ve searched far and wide and have tried different PHP code and nothing seems to help.

Thank you in advance!

HTML:

[code]

Help us make the site better... ...

Help us make the site better

Tell us your thoughts and recieve $10 off your purchase of $50 or more.

Which products do you find the most useful?
What other types of products would you like to see on the site?
What types of products do you usually purchase on the site?
Check all that apply
Gifts or rewards for consultants
Business supplies for new consultants
Business supplies for yourself
What other suggestions do you have for the site?
Your email address
We will send the promotion code to this address


[/code]

Here is my PHP:
[php]

Emailing Form Data... ... <?php //This is a very simple PHP script that outputs the name of each bit of information (that corresponds to the name attribute for that field) along with the value that was sent with it right in the browser window, and then sends it all to an email address (once you've added it to the script). if (empty($_POST)) { print "

No data was submitted.

"; print ""; exit(); } //Creates function that removes magic escaping, if it's been applied, from values and then removes extra newlines and returns to foil spammers. Thanks Larry Ullman! function clear_user_input($value) { if (get_magic_quotes_gpc()) $value=stripslashes($value); $value= str_replace( "\n", '', trim($value)); $value= str_replace( "\r", '', $value); return $value; } if ($_POST['comments'] == 'Please share any comments you have here') $_POST['comments'] = ''; //Create body of message by cleaning each field and then appending each name and value to it $body ="Here is the data that was submitted:\n"; foreach ($_POST as $key => $value) { $key = clear_user_input($key); $value = clear_user_input($value); if ($key=='extras') { if (is_array($_POST['extras']) ){ $body .= "$key: "; $counter =1; foreach ($_POST['extras'] as $value) { //Add comma and space until last element if (sizeof($_POST['extras']) == $counter) { $body .= "$value\n"; break;} else { $body .= "$value, "; $counter += 1; } } } else { $body .= "$key: $value\n"; } } else { $body .= "$key: $value\n"; } } extract($_POST); //removes newlines and returns from $email and $name so they can't smuggle extra email addresses for spammers $email = clear_user_input($email); $name = clear_user_input($name); //Create header that puts email in From box along with name in parentheses and sends bcc to alternate address $from='From: '. $email . "(" . $name . ")" . "\r\n" . 'Bcc: [email protected]' . "\r\n"; //Creates intelligible subject line that also shows me where it came from $subject = 'SRVP Survey Results'; //Sends mail to me, with elements created above mail ('[email protected]', $subject, $body, $from); ?>

Thank you

Thank you for your comments, we appreciate your time.

You will recieve an email from us within 48 hours with your coupon code.

[/php]

As you are using:

purchase[]

The checkboxes will be put into an array. You could either use this array (by looping through it or accessing each item directly) or replace the checkboxes name attributes with something else, e.g. purchase1, purchase2 and then use the values that way.

Sponsor our Newsletter | Privacy Policy | Terms of Service