Buy Now
Sign in

Problem with saving checkbox options in databse table

bhabdi , September 30 2010
B
bhabdi 9
September 30 2010 #58396
Hi everyone,
I have a problem saving checkbox options submitted by users, in the database table,
My check box has 12 options, the problem is no matter how many and which options are selected by users, ONLY the last option which they have selected is stored in the database table.

i mean if a user chooses option 1, option 2 and option 6, if you look at database table, you see only option 6!!! where are option1 and option2 going?

That's Because i removed
  • from the name of checkbox...
    when in put
  • after the checkbox name in HTML code, nothing is e-mailed and nothing is saved in database table

    any idea?
    B
    bhabdi 9
    October 01 2010 #58410
    in the form HTML code, if i put
  • after checkbox name (like check2
  • ) nothing is saved in the table database
    and
    if i remove [] and only have "check2" as checkbox name, only one of the options is saved in the database table..

    confused ..

    what shall i do?
    B
    bhabdi 9
    October 01 2010 #58413
    ChronoForms handle my posted arrays: YES

    Email the results ? YES
    Debug:

    1. Form passed first SPAM check OK
    2. Form passed the submissions limit (if enabled) OK
    3. Form passed the Image verification (if enabled) OK
    4. Form passed the server side validation (if enabled) OK
    5. $_POST Array: Array ( [text_1] => TEST [radio0] => مرد [radio1] => متاهل [text_18] => 1 [text_4] => 13 [select_2] => اردیبهشت [text_3] => 1985 [text_8] => 123456789 [text_9] => 321654987 [text_10] => [email]Example@example.com[/email] [text_12] => LA [text_13] => US [text_11] => Address [check2] => Array ( [0] => شیر [1] => پنیر [2] => آب میوه ) [chrono_verification] => RiXcC [button_14] => ثبت [df37abf54e8115e90ccd934b3d3aa435] => 1 [1cf1] => 366adb4e05be96317517f5ff6d7fcdba [chronoformname] => moshtarak )
    6. $_FILES Array: Array ( )
    7. Form passed the plugins step (if enabled) OK
    GreyHead 63.4
    October 01 2010 #58420
    Hi bhabdi,

    The settings look correct - you do need the [] to give you an array of results.

    What displays in the 'dummy email' on the Debug page please?

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bhabdi 9
    October 01 2010 #58423
    dear bob,
    thank you for your response,

    i copied and pasted all the code in the debug page,
    excuse me, but i do not know where should i find the dummy email stuff you asked for, would you mind give me some information

    I have the [] in my html code as well. what do you think about this problem? do you like me copy the Html code form here?
    GreyHead 63.4
    October 01 2010 #58424
    Hi bhabdi,

    Oops, sorry, you don't have emails turned on.

    Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bhabdi 9
    October 01 2010 #58425
    Thank you very very much for your soon responses and your will to help users and your responsibility.
    I attached the backup form
    Attachments
    moshtarak.zip
    (5.12 KiB)
    131 Downloads/Views
    GreyHead 63.4
    October 01 2010 #58427
    Hi bhabdi,

    I checked the email and the Checkbox array appears to be working OK. I'll look at the Database save later.

    Bob
    Attachments
    01-10-2010 13-28-41.png
    01-10-2010 13-28-41.png
    (35.82 KiB)
    2097 Downloads/Views
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bhabdi 9
    October 01 2010 #58428
    Oh my god!
    didn't you change any settings or parameters?

    I am really shocked!!

    the main form address is here: http://pakbandairy.com/index.php?option=com_content&view=article&id=76&Itemid=30

    but when i fill the form, all data except the checkbox is stored in database...the e-mail is blank in {check2} location...
    I saw the pic above, but it seems neither DATABASE saving, nor email information doesn't work on the server...
    how is it possible? what should i do now?
    GreyHead 63.4
    October 01 2010 #58429
    Hi bhabdi,

    . . . and the database save works OK too. (I changed the DB Connection setting to After Email which is the default).

    Please check that the DB column is called check2 (and not check_2 or check2[])

    I don't think I made any other changes that would affect the email or the Database saving. I did change the To addresses in the emails* so that they came to me and I turned off ImageVerification to make it easier to test.

    Bob

    *I strongly recommend that you do *not* use the Dynamic From Email element in your Email Setups. Using this often results in your emails being marked as spam and dropped into a spam filter. Instead use the static From Email with an address that matches the site domain name and use Dynamic ReplyTo Email for the user email. The result is the same but with a much better chance of good delivery.
    Attachments
    01-10-2010 14-26-41.png
    01-10-2010 14-26-41.png
    (7.01 KiB)
    2081 Downloads/Views
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bhabdi 9
    October 01 2010 #58446
    dear bob,
    thank you for your answer, although, I can not save neither the data in database, nor in email.
    I checked the database column and it was check2
    i even disable the image verification too, to assure that i am exactly doing what you have done, to get the result.
    but the result is still negative...

    really confused.

    should i write something at On Submit code - before/after sending email box?

    why is it ok on your side and not ok on my side?
    i have removed the cf_user_id column from db columns. it is a ridiculous question, but could it be from that?
    GreyHead 63.4
    October 01 2010 #58447
    Hi bhabdi,

    By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    GreyHead 63.4
    October 03 2010 #58538
    Hi bhabdi,

    If you turn off the Email Verification Plug-in then the arrays save correctly and the emails are sent. I'm not quite sure why this works like this though :-(

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bhabdi 9
    October 03 2010 #58539
    dear bob,
    thank you for checking the form for me,
    so now,
    in this case how can i verify the e-mail addresses of users? it seems that S*P*ams are getting invited!
    GreyHead 63.4
    October 03 2010 #58541
    Hi bhabdi ,

    I'm not sure . . . I'll need to go and dig into the code to see if I can work out what is happening here. I haven't seen this before :-(

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    H
    hooky 1
    October 24 2010 #59564
    Hi,

    I had the same problem, and it took me some time to figure it out.

    Find line 299 in cf_email_verification.php,

    //save the data
    $posted[$params->get('vflagfield')] = 0;
    if ( !empty($MyForm->formrow->autogenerated) ) {
      eval( "?>".$MyForm->formrow->autogenerated );
    }


    and add the handleArrays method.

    //save the data
    $MyForm->handleArrays($MyForm->formrow->name);
    $posted[$params->get('vflagfield')] = 0;
    if ( !empty($MyForm->formrow->autogenerated) ) {
      eval( "?>".$MyForm->formrow->autogenerated );
    }


    With that, checkbox and radiobutton options get saved to the database.
    You should check that "ChronoForms handle my posted arrays" option is set to "yes" in the General tab of the Forms Management panel.

    Daniel