Menu

checkbox options not displaying in my databas

Help
Jara Baker
2010-03-07
2013-06-03
  • Jara Baker

    Jara Baker - 2010-03-07

    I feel like I'm going crazy, I created a form with checkboxes here is a snippet of the html:
    <li class="mainForm" id="fieldBox_25"> <label
    class="formFieldQuestion">Please let us know how
    you'd like to get involved. Please check all that apply.&nbsp;*</label><span><input
    class="mainForm" name="field_25" id="field_25_option_1"
    value="Focus Group" type="checkbox"><label class="formFieldOption"
    for="field_25_option_1">Focus
    Group</label><input class="mainForm" name="field_25"
    id="field_25_option_2" value="Product Survey" type="checkbox"><label
    class="formFieldOption" for="field_25_option_2">Product
    Survey</label><input class="mainForm" name="field_25"
    id="field_25_option_3" value="Product Testing" type="checkbox"><label
    class="formFieldOption" for="field_25_option_3">Product
    Testing</label><input class="mainForm" name="field_25"
    id="field_25_option_4"
    value="Special Offers, Contests, More Information" type="checkbox"><label
    class="formFieldOption" for="field_25_option_4">Special
    Offers, Contests, More Information</label></span>
        </li>
    Here is the php code:
    // Checkbox handling
    $field_25_opts = $_POST.",". $_POST.",". $_POST.",". $_POST;

    When I check my database after doing a few test runs, all I see in my SQLdatabase is "array" under field_25.  I want it to show the selections selected

    Am I doing something wrong? Is it my database? Is it the php code? Is it the HTML? is it everything I done?  So far every field on the form works perfectly its the checkboxes!!!

     
  • TNTEverett

    TNTEverett - 2010-03-08

    Check Box options form an array.  If you use the array pointer in the process.php code then you will see the message "array" in your db or where ever else you use the array pointer.  You will need to store the individual check box values instead if that is what you wish to see in the db. 
    If the value stored in the db is an array then you can extract the array and post process it to display the individual values.  Either way will take some small amount of work to sort it out. 

     
  • Zachary

    Zachary - 2010-03-15

    I ran into this same issue, however, looking at the source code (processor.php), there is actually a bug in generating the INSERT SQL code. 

    At the top of the page, you will see some similar lines:

    // Checkbox handling
    $field_9_opts = $_POST.",". $_POST.",". $_POST;

    Look for the field, in this case field_9 in the INSERT line, and replace $_POST with $field_9_opts.  This will insert the names of the fields into the field in the database.

     
  • Danny Virasawmi

    Danny Virasawmi - 2010-09-27

    I had the same issue also. I had to change my processor.php file a little.

    I noticed that it was displaying correctly in the emails the form was sending me but not in the database. In the processor.php file, I found the value what was being sent to my email for my checkbox area, copied it, and used that to replace what was being written to the database field.

    Tested it and it works fine now. It still has extra commas in it, but i I don't mind that.

    I am running phpFormGenerator v3.0.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.