dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: check box values with php

  1. #1
    Member
    Join Date
    Nov 2000
    Location
    california
    Posts
    56

    check box values with php

    i got this on line form and I use PHP as the backend. all the text boxes and drop down list values get sent but how to I work it so that a radio button or check box values gets sent?
    thanks

  2. #2
    Junior Member
    Join Date
    Jun 2006
    Posts
    1
    Hi

    I'm currently working on email forms in Flash and have managed to get the information from basic text fields sent to my email using PHP...

    I noticed you have managed to sort combo boxes out, so the info come back to you...

    Any chance of some help, its been driving me mad now for about a week...

    Cheers

  3. #3
    Senior Member
    Join Date
    Apr 2000
    Posts
    101

    Dramaphree

    did you ever figure out teh check box issue? I'm trying to figure that out myself... Send me some help if you can.

    Thanks
    Mike C

  4. #4
    associate admedia's Avatar
    Join Date
    Oct 2001
    Location
    is
    Posts
    1,347
    Check Boxes:

    An unchecked checkbox will Submit nothing to the php script....
    So to see if a checkbox was check you would do something like this
    PHP Code:
    if(isset($_REQUEST['mycheckbox'])){
       
    // mycheckbox was checked, so lets put the value in a variable
       
    $myvariable $_REQUEST['mycheckbox'];

    A radio button is different.
    A submitted radio button will contain the value of the selected button...
    PHP Code:
    $myvalue $_REQUEST['myradiogroup']; 

  5. #5
    Wannabe PHP Wizard
    Join Date
    Nov 2001
    Location
    Leechburg, PA
    Posts
    129
    So, you would basicly set your box up like this:

    PHP Code:
    <input type="checkbox" name="live_switch" value="y" <? if($live == 'y'){ ?>checked<? ?>/>
    The checked portion is if you happen to get the value from your database and set it. This does not work with Safari for some reason. I have to use "Yes", "No" Drop down boxes for Safari users. If you don't use data from a database, just use...

    <input type="checkbox" name="live_switch" value="y" />

    Then, when you are processing...

    PHP Code:
    <?
    if($_POST['live_switch'] == 'y'){
         
    $checked 'yes';
    } else {
         
    $checked 'no';
    }
    ?>
    Clinton N Godlesky
    My Stuff:
    http://www.15656.com/clint http://www.statedirt.com
    Personal Development Projects:
    http://www.15656.com/dev

  6. #6
    associate admedia's Avatar
    Join Date
    Oct 2001
    Location
    is
    Posts
    1,347
    Your check-box setup looks ok, but you need to check for the variable beforehand.... see if the post variable is even sent with isset($_REQUEST['live_switch']);

    So to complete your first code I would write
    PHP Code:
    if(isset($_REQUEST['live_switch'])){
    /* the box is checked so it must be set
    to the only value it is allowed,
    which in this case would be y */
         $live = 'y';
    }
    <input type="checkbox" name="live_switch" value="y" <?php if($live == 'y') echo "checked"  ?> />
    The second part, again, check that the checkbox was selected and sent with isset.
    PHP Code:
    if(isset($_REQUEST['live_switch'])){
        
    // the checkbox was sent, it must be selected
        
    $checked true;
    }else{
        
    // the check box wasn't checked... nothing was sent.
        
    $checked false;
    }
    ?> 
    Last edited by admedia; 10-05-2006 at 08:41 PM.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center