Email recipient based on user selection

Post any questions you may have here

Email recipient based on user selection

Postby coalescefl on Sun May 11, 2008 7:14 pm

Im trying to build a form that emails the form submission to a different person based on a selection list.

For example, the question reads:
I would like more information on:
- Real Estate
- Membership
- Choice 3
- Choice 4

If someone chooses option 1, a copy of the form is emailed to department 1, if option 2, a copy goes to department #2, etc.

Is something like this possible? Any help would be greatly apreciated.

Thanks :)
coalescefl
Fresh Boarder
 
Posts: 1
Joined: Sun May 11, 2008 4:25 pm

Re:Email recipient based on user selection

Postby admin on Sun May 11, 2008 8:26 pm

Possible, in the onsubmit before email :

Code: Select all
<?php
if($_POST['real_estate_field']){
$rows[0]->extraemail .= "rea_estate@yourdomain.com";
}
?>


and so...

Cheers

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 4283
Joined: Mon Aug 14, 2006 5:29 am

Re:Email recipient based on user selection

Postby mancourt on Sun May 11, 2008 9:55 pm

Thank you for your prompt reply! However it's not working =/

I tried the above code and modded it to this to fit the value name:
Code: Select all
<?php
if($_POST['real_estate']){
$rows[0]->extraemail .= "email@domain.com";
}
?>



Also the page in question can be found here:
http://goldenocala.coalescecreative.com ... ntact_form

Also here is the bit of the form that's pertinate:
Code: Select all
<select name="more_info" size="4" multiple id="more_info">
            <option value="real_estate">Real Estate</option>
            <option value="membership">Membership</option>
            <option value="banquet">Banquet/Catering</option>
            <option value="employment">Employment</option>
             </select>
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby admin on Tue May 13, 2008 3:27 pm

Hi, sorry my mistake, make this line like this :

Code: Select all
$rows[0]->extraemail .= ",rea_estate@yourdomain.com";


cheers

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 4283
Joined: Mon Aug 14, 2006 5:29 am

Re:Email recipient based on user selection

Postby mancourt on Wed May 14, 2008 12:33 am

Max, thank you again for your reply. Still no dice on the extra E-mails coming in. The primary E-mail is receiving everything fine, just not the ones in here:

<?php
if($_POST['membership']){
$rows[0]->extraemail .= ",email@domain.com";
}
?>

Any other ideas? Thank you
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby GreyHead on Wed May 14, 2008 10:18 am

Hi mancourt,

I'd add a line of diagnostic code in there:
Code: Select all
<?php
if ( $debug ) {
  echo "extraemail: "; print_r($rows[0]->extraemail);echo "<br />";
}
if ( $_POST['membership'] ) {
  $rows[0]->extraemail .= ",email@domain.com";
  if ( $debug ) {
    echo "extraemail: "; print_r($rows[0]->extraemail);echo "<br />";
  }
}
?>
when debug is on this should print out a line showing you what's in 'extraemail' before and after the change.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3962
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Email recipient based on user selection

Postby mancourt on Wed May 14, 2008 1:27 pm

Bob, thanks again for your reply.

Here is what the debug code popped out:
_POST: Array ( [action] => submit [first_name] => NAME [last_name] => LAST NAME [street] => STREET ADDRESS [city] => Port Orange [state] => Florida [zip] => 32127 [phone_daytime] => [phone_evening] => [fax] => [email] => justin@mydomain.com [contact_preference] => E-mail Address [more_info] => membership [comments] => testing [button] => Submit )
Case 1: Use table layout
extraemail: mainemail@domain.com
E-mail: 'Yes' custom
Email sent


For some reason the extraemail field is just using whatever the default E-mail I setup, not the one I put in the PHP onsubmit field. It's as if the PHP onsubmit code isn't overriding the default E-mail address for the form.?
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby GreyHead on Wed May 14, 2008 1:36 pm

Hi mancourt,

The PHP check is checking
Code: Select all
if ( $_POST['membership'] ) {
but there's no 'membership' field there. I think it should be:
Code: Select all
Code:
<?php
if ( $debug ) {
  echo "extraemail: "; print_r($rows[0]->extraemail);echo "<br />";
}
if ( $_POST['more_info'] == 'membership' ) {
  $rows[0]->extraemail .= ",email@domain.com";
  if ( $debug ) {
    echo "extraemail: "; print_r($rows[0]->extraemail);echo "<br />";
  }
}
?>
Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3962
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Email recipient based on user selection

Postby mancourt on Thu May 15, 2008 12:58 am

Bob I think you nailed it! Thank you for the excellent support :)
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby mancourt on Wed Jun 25, 2008 1:09 pm

Bob, wanted to follow up. Is it possible to get the code above to work with a checkbox scenario so it's easier for users to make multiple selections?
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby GreyHead on Wed Jun 25, 2008 1:16 pm

Hi mancourt,

Yes. Collect the checkbox replies in an array and then run through the array and add an email address for each entry in there.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3962
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Email recipient based on user selection

Postby mancourt on Thu Jun 26, 2008 3:02 am

Bob, you've already helped me out enough on this one, but could someone help me on building an "array" to make this possible?
mancourt
Fresh Boarder
 
Posts: 6
Joined: Sun May 11, 2008 4:23 pm

Re:Email recipient based on user selection

Postby GreyHead on Thu Jun 26, 2008 12:47 pm

Hi mancourt,

Use this kind of name for yoru checkboxes:
Code: Select all
<input type="checkbox" name="checkbox[]" value="value_1" />
<input type="checkbox" name="checkbox[]" value="value_2" />
. . .
and the results will be in the 'checkbox' array.

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3962
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany


Return to ChronoForms Questions & Answers

Who is online

Users browsing this forum: GreyHead, MSNbot Media, Yahoo [Bot] and 2 guests