Forums

Processing Checkboxes On Submit after Email

khenn 05 Jan, 2010
I am using ChronoForms 3.1 RC5.5 with Joomla 1.5.15.

First, I have a question. Why when trying to print the submitted form values of input fields in the on submit before or after email do they only display if I run them in the "on submit after email". For instance, if I put

<?php echo "hello";?>


in the on submit before, it will not display. However, if I put it in the after, it does display?

Now, onto my real question...

I have searched the forums, and thought I had the answer, but this doesn't seem to work. I have 6 checkboxes on a form, and each one has the name "terms[]" with a different value. If I check all of the boxes and submit the form, I can see (using HttpFox) that all of the terms[] are in the request. However, I can not get them out. I have tried the foreach like this:

foreach ( $_POST['terms'] as $term ) {
  echo "$term ";
}


I've also tried the implode like this:

echo implode(" ", $_POST['terms']);


What am I missing?

Thanks,
Kris
GreyHead 05 Jan, 2010
Hi khenn,

The OnSubmit Before code is only executed if you have 'Send Emails' set to 'Yes' in the form General tab.

Bob
khenn 05 Jan, 2010
Thanks GreyHead, what about my other question...

Kris
GreyHead 05 Jan, 2010
Hi Kris,

I'm not sure why your checkbox code doesn't work. Try setting "ChronoForms handle my posted arrays:" to 'Yes' on the Form General tab, that usually sorts out check-box problems.

Bob
khenn 05 Jan, 2010
Ok, well I checked my setting for "ChronoForms handle my posted arrays:", and it was already set to "Yes". So I thought I'd try changing it to "No", and now my checkbox information gets displayed when using the implode. The foreach loops works too.

However, I had another checkbox on the page with only one option. If you only have one checkbox and the user doesn't mark it, or multiple and they don't mark any, then you will get a warning on the page like this...

Warning: implode() [function.implode]: Invalid arguments passed in /home/testing/public_html/components/com_chronocontact/libraries/customcode.php(51) : eval()'d code on line 94
GreyHead 05 Jan, 2010
Hi Kris,

The error message is from your implode code (line 94 of your OnSubmit code). An empty checkbox doesn't return any entry in $_POST so you need to check for that before imploding.

Bob
This topic is locked and no more replies can be posted.