Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: PHP Checkbox

  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Checkbox

    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">
    <tr>
    <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" />
    Tent<br/>
    <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"/>
    </form>


    Here's my php as is:

    <?
    error_reporting(E_ALL);

    $to='myemail@gmail.com';
    $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
    Last edited by hans8233; 02-10-2010 at 02:58 AM.

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Try using <?php instead of <?. IIRC, 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.
    Last edited by bdl; 02-10-2010 at 03:33 AM. Reason: Added link.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •