Impossible to save data into the database

Francois 09 Dec, 2009
Hi all,

I have a problem about the storage of data in the database.
I decided not to email the result so my form is configured like this in the administration (Email the results ? No)
I managed my email into the 'On Submit code - after sending email' fields and I did like this post

But now, I have the impression that the data are stored in database only if the option Email the result is set to 'Yes' ?

Could you please help me to solve my problem please ?
Where can I modify code in order to save my data even if 'Email the results == No'

Thank you so much in advance
GreyHead 09 Dec, 2009
Hi Francois,

If you aren't emailing the results why are you using the 'Email with checkboxes' code in the OnSubmit After Box? That makes no sense to me at all??

If you are using that code then it needs to go into the OnSubmit Before Box and emails need to be enabled in the form General Tab.

I guess that your database save isn't working because you have Emails disabled in the General Tab and the DB Connection set to 'Before Email' - set it back to the default 'After Email' and it will probably work OK.

Francois 09 Dec, 2009

Thank you for your response.
I appreciate your reactivity.

I think I have to give you more information. In fact, in the 'OnSubmit After Box', I call a webservice which give an answer :

(Example of webservice result code :
00000 = success
02101 = failure

Beside, I created 4 emails template in my form and I send 2 emails when the result is 00000 and I send the two other email when the result is 02101. Emails depends on the result of my webservice, that's why I develop the code in the 'OnSubmit After Box' because I did not know how to send email separatly :

if (response == '02500')
{$formname = 'Compte';
$MyForm =& CFChronoForm::getInstance($formname);
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'enabled', 0);
$MyFormEmails->setEmailData(2, 'enabled', 0);
$MyFormEmails->setEmailData(3, 'enabled', 1);
$MyFormEmails->setEmailData(4, 'enabled', 1);
//enable 3nd email Mail au support pour annoncer l'echec de la création du compte
$MyFormEmails->sendEmails($MyForm, $MyFormEmails->emails);

Effectively, I have Emails disabled in the General Tab but the DB Connection set to 'after Email'.
But it still not working and my data are not stored.

I will appreciate your help again and I hope you will understand my english.
Thank you again
I hope you will be able to help me. If you need more code or anything, I can give it to you
GreyHead 11 Dec, 2009
Hi Francois,

It sounds to me as though you should turn emails ON in the Form General tab.

Put the webservice code in the OnSubmit Before Box* (or use the cURL plugin to access the service).

Also in the OnSubmit Before box add the code to respond to the webservice and enable or disable the emails.

Set the database save to the default of After Emails.


* The Onsubmit before code is not executed unless emails are ON in the Form General tab.
This topic is locked and no more replies can be posted.