Forums

email array

schlogo 26 Jan, 2009
Hello

I ve been using a multiple email form for quite a while in a previous version of chronoforms. Now i ve upgraded to 3.0 and it does not work anymore, here s where I stand now:

in the email, a basic select:

<SELECT name="departments[]" class=cf_inputbox id="departments"  >
  <option value="dep1">dep1</option>
  <option value="dep2">dep2</option>
  <option value="dep3">dep3</option>
  <option value="dep4">dep4</option>
  <option value="dep5">dep5</option>
</SELECT>


and the the subit before email, this php code

<?php 
$emails = array(
'dep1' => 'dep1@dep1.com', 
'dep2' => 'dep2@dep2.com', 
'dep3' => 'dep3@dep3.com', 
'dep4' => 'dep4@dep4.com', 
'dep5' => 'dep5@dep5.com');

$em_array= array();
foreach ( $_POST['departments'] as $em ) {
$em_array[] = $emails[$em];
}
$emails[0]->to = implode(",", $em_array);
?>


I know i wrong but i can t find where. Any help is welcome
schlogo 26 Jan, 2009
anyone? 🤨
GreyHead 26 Jan, 2009
Hi schlogo,

I think it needs to be $email->to

Bob
schlogo 26 Jan, 2009
hello

tks for your answer, i ve made the change but nothing happens :?
schlogo 26 Jan, 2009
i am using dynamic to in the mail form, is it correct?
GreyHead 27 Jan, 2009
Hi schlogo,

Later: please ignore this and see my next post

I think that dynamic to is $email->dto but either should work. I'll check the code again this morning and see if the OnSubmit Before code is executed at a useful time.

Bob
GreyHead 27 Jan, 2009
Hi schlogo,

The $email approach won't work because $email is loaded after the OnSubmit Before code so anything you put in there will be overwritten.

Instead do this:[list]
  • put a hidden field in your form with an empty value and a name of say 'email_to'
  • Put this field name in the Dynamic To field of your Email setup
  • In the OnSubmit Before box user JRequest::setVar('email_to', 'post') to write a comma separated list of addresses
  • [/list]

    Bob
    schlogo 27 Jan, 2009
    arf, i can't get it to work and i do not see any setvar example on the forum that could help, i m lost
    schlogo 27 Jan, 2009
    i am not sure to understand, why would i want to create a hidden field , where would i get the email from the dropdown?
    GreyHead 27 Jan, 2009
    Hi schlogo,

    JRequest::setVar() and JRequest::getVar() are the standard Joomla 1.5 methods for setting and getting variables from the $_REQUEST, $_POST, $_GET and $_COOKIE arrays. They provide a bit more security than using the arrays directly.

    You may not need the hidden field - it's a way of making sure that ChronoForms knows that a field exists and adds it to the database but you won't need thsi if you are only using the results for the Email.

    Bob
    Max_admin 27 Jan, 2009
    Hi schlogo,

    using the first code in the first post here, did you have any emails setup and enabled ? you must have at least 1 working email before you try this code!

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    schlogo 27 Jan, 2009
    do you mean I can't use dynamic to alone?
    Max_admin 27 Jan, 2009
    Hi,

    this line :
    $emails[0]->to = implode(",", $em_array);


    will get executed ONLY if some email is setup there and enabled, you need to have at least 1 email there enabled and ready to email, try to remove all this code and test the form with a static email first, when it works then add your code to the onsubmit before email box and test and I think it should work! let me know!

    Regards
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    This topic is locked and no more replies can be posted.