Hi Everyone,
I am new to ChronoForms so I apologize for possibly asking questions about stuff might be obvious for someone else.
I have a Contact Us form on our website. After the form is filled in, I want to send an email to one or more recipients depending on checkboxes ticked in on the form. I tried several different ways to do it, but they all failed. Eventually I found FAQ #31 to be refferred to often as a solution to problems similar to my one. I copied and customized the code, but when I try to use it, server throws Error 500.
Please find the code below. It runs 'On submit' event before the email sending action.
If I run the code without the part taken from the FAQ, it works (obviously does not do too much, but no error is thrown). If I add the first line of the code taken from the FAQ, it does not throw any error. However if I put any code referring to $MyForm, it throws error 500. Obviously if I put all the 3 lines from FAQ, it throws error.
I could not get any further, as I am not very experienced PHP user either. What I noticed is that code of 3 lines is often quoted when I use Google, that is the why I do not get why it throws error 500.
Thank you for any kind of help in advance.
Kind regards,
Istvan
I am new to ChronoForms so I apologize for possibly asking questions about stuff might be obvious for someone else.
I have a Contact Us form on our website. After the form is filled in, I want to send an email to one or more recipients depending on checkboxes ticked in on the form. I tried several different ways to do it, but they all failed. Eventually I found FAQ #31 to be refferred to often as a solution to problems similar to my one. I copied and customized the code, but when I try to use it, server throws Error 500.
Please find the code below. It runs 'On submit' event before the email sending action.
<?php
$adrlist="";
if (isset($_POST["input_cbg_property"])){if (!empty($adrlist)){$adrlist=$adrlist.",";}$adrlist=$adrlist."user1@company.com";}
if (isset($_POST["input_cbg_services"])){if (!empty($adrlist)){$adrlist=$adrlist.",";}$adrlist=$adrlist."user2@company.com";}
//This code is taken from FAQ - START
$MyForm =& CFChronoForm::getInstance('Form_ContactUS');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1,'to',$adrlist);
//This code is taken from FAQ - END
?>
If I run the code without the part taken from the FAQ, it works (obviously does not do too much, but no error is thrown). If I add the first line of the code taken from the FAQ, it does not throw any error. However if I put any code referring to $MyForm, it throws error 500. Obviously if I put all the 3 lines from FAQ, it throws error.
I could not get any further, as I am not very experienced PHP user either. What I noticed is that code of 3 lines is often quoted when I use Google, that is the why I do not get why it throws error 500.
Thank you for any kind of help in advance.
Kind regards,
Istvan