View Full Version : PHP Checkbox

02-10-2010, 01:53 AM
Hi All-
Sorry to post again, need some help on this. I made a checkbox for my registry on my site. It's a home-made gift registry, so I have a checkbox form at bottom of page for people to notify us when they got a gift. I just want them to check the gift, hit submit, and I would get an email saying which gift(s) they checked.

Here's my form html:
<form action="checkbox-form.php" method="post">
<td><span class="style1"><span class="style1">Please let us know if you got us one of these gifts!<br />

<input type="checkbox" name="giftBought[]" value="Pasta_Maker" />
Pasta Maker<br />
<input type="checkbox" name="giftBought[]" value="Ravioli_Attachment" />
Ravioli Attachment<br />
<input type="checkbox" name="giftBought[]" value="Coffee_Pot" />
Coffee Pot<br />
<input type="checkbox" name="giftBought[]" value="Lantern" />
Lantern<br />
<input type="checkbox" name="giftBought[]" value="Tent" />
<input type="checkbox" name="giftBought[]" value="SleepingBag" />
Sleeping Bag<br/>
<input type="checkbox" name="giftBought[]" value="SleepingBag" />
Sleeping Bag<br/>
<input type="checkbox" name="giftBought[]" value="iPod_Radio" />
Ipod Radio</span><br/>
<input type="image" name="formSubmit" value="Submit" src="rsvp_menubtns/submit.png"/>

Here's my php as is:


$subject = "Registry Purchase";

foreach($_POST['giftBought'] as $value) {
$check_msg .= "Checked: $value\n";

$body = "Item: $check_msg";


It's just going to a blank php, and I'm not getting an errors. Anythoughts?

Thanks so much! I'm trying to get this done to keep my future (hopefully) wife's sanity :)

02-10-2010, 02:31 AM
Try using <?php instead of <?. IIRC, short_open_tag (http://us3.php.net/manual/en/ini.core.php#ini.short-open-tag) is 'off' by default, so using <? won't work. Otherwise I see no syntax errors.

Please be sure to post using the PHP code tags, and indent for readability.