Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-26-2003, 10:57 AM   #1
nickel
Registered User
 
Join Date: Jul 2003
Posts: 8
Default PHP variables for check boxes

I'm using a mail contact form that has several check boxes along with a comments box and user's email, etc.....i have it working so far but i don't know what PHP variables to assign to the check boxes. How would i get the selected check boxes to show up in the final email? Can't find help on this anywhere so far.....
nickel is offline   Reply With Quote
Old 08-27-2003, 10:54 PM   #2
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Does each checkbox belong to the same group? I provided an exaple for both single items and for grouped items

PHP Code:
<?php
    
if($_REQUEST['submit'])
    {
        print 
"You selected:<br>";
        print 
"<ul>";
        foreach(
$_REQUEST['options'] as $k => $v)
        {
            print 
"<li>$v</li>";
        }
        print 
"</ul>";
        if(
$_REQUEST['newsletter'] != "")
        {
            print 
"Should I subscribe: ".$_REQUEST['newsletter'];
        }
        else
        {
            print 
"Should I subscribe: no";
        }
        exit;
    }
?>
<form action="<?php print $GLOBALS['PHP_SELF']; ?>" method="post">
<input type="checkbox" name="options[]" value="option 1">Option 1<br>
<input type="checkbox" name="options[]" value="option 2">Option 2<br>
<input type="checkbox" name="options[]" value="option 3">Option 3<br>
<input type="checkbox" name="options[]" value="option 4">Option 4<br>
<input type="checkbox" name="options[]" value="option 5">Option 5<br>
<input type="checkbox" name="options[]" value="option 6">Option 6<br>
<input type="checkbox" name="options[]" value="option 7">Option 7<br>
<input type="checkbox" name="options[]" value="option 8">Option 8<br>
<input type="checkbox" name="options[]" value="option 9">Option 9<br>
<input type="checkbox" name="options[]" value="option 10">Option 10<br>
<input type="checkbox" name="options[]" value="option 11">Option 11<br>
<input type="checkbox" name="newsletter" value="subscribe">Newsletter<br>

<input type="submit" name="submit" value="Submit">
</form>
freddycodes is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:56 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.