Hello,
i have a Form with 2 Checkboxes:
Webmaster
Pastor
Depending on which checkbox is selected, an e-mail to the "Webmaster" or "pastor" is sent.
I have did it with the following Code (On Submit code - before sending email:)
When i select the Checkbox "Webmaster", the E-Mail is send to the Webmaster.
Exactly the same is, when i select the Checkbox "pastor" the E-Mail is sent to the Pastor.
This works very well.
My Problem is, when i selct both no E-Mail where send. What could be wrong?
Regards
Blondie
P.S: Sorry for my bad English....
i have a Form with 2 Checkboxes:
Webmaster
Pastor
Depending on which checkbox is selected, an e-mail to the "Webmaster" or "pastor" is sent.
I have did it with the following Code (On Submit code - before sending email:)
<?php
$MyForm =& CFChronoForm::getInstance("$formname");
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$copyme = JRequest::getVar('check0', array(), 'POST', 'array', 0);
if (in_array('Webmaster', $copyme))
{
$MyFormEmails->setEmailData(1, 'enabled', '1');
}
if (in_array('Pastor', $copyme))
{
$MyFormEmails->setEmailData(2, 'enabled', '1');
}
?>
When i select the Checkbox "Webmaster", the E-Mail is send to the Webmaster.
Exactly the same is, when i select the Checkbox "pastor" the E-Mail is sent to the Pastor.
This works very well.
My Problem is, when i selct both no E-Mail where send. What could be wrong?
Regards
Blondie
P.S: Sorry for my bad English....
Hello again,
i have found an solution.
If I have checked both checkboxes, i have "Pastor, Webmaster" in the variable $copyme.
I haved tried to split the variable with
but i dont know if it works. I never had programmed in Php.
With only 2 Checkboxes the code are working well. But with 3 ore more checkboxes the code is be very complicated. I have also tried it with preg_match, but this will only working with strings not with arrays.
Does anybody knows a better solution? I think, when this will working without
then the code is very simple, and it is an Example for the FAQ section?
Greetings
Blondie
i have found an solution.
<?php
$MyForm =& CFChronoForm::getInstance("$formname");
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$copyme = JRequest::getVar('check0', array(), 'POST', 'array', 0);
if (in_array('Webmaster', $copyme))
{
$MyFormEmails->setEmailData(1, 'enabled', '1');
}
if (in_array('Pastor', $copyme))
{
$MyFormEmails->setEmailData(2, 'enabled', '1');
}
if (in_array('Pastor, Webmaster', $copyme))
{
$MyFormEmails->setEmailData(1, 'enabled', '1');
$MyFormEmails->setEmailData(2, 'enabled', '1');
}
?>
If I have checked both checkboxes, i have "Pastor, Webmaster" in the variable $copyme.
I haved tried to split the variable with
$copyme2 = explode(",", $copyme);
but i dont know if it works. I never had programmed in Php.
With only 2 Checkboxes the code are working well. But with 3 ore more checkboxes the code is be very complicated. I have also tried it with preg_match, but this will only working with strings not with arrays.
if (preg_match("/Pastor/i", $copyme)) {
$MyFormEmails->setEmailData(1, 'enabled', '1');
}
Does anybody knows a better solution? I think, when this will working without
if (in_array('Pastor, Webmaster', $copyme))
{
$MyFormEmails->setEmailData(1, 'enabled', '1');
$MyFormEmails->setEmailData(2, 'enabled', '1');
}
then the code is very simple, and it is an Example for the FAQ section?
Greetings
Blondie
This topic is locked and no more replies can be posted.