Sending form to diff email depending on what people check

We have a form activated by PHP form action: a few items can be ticked. Depending on what people tick the form need to be send to different email addresses. Any idea how to do that?
Thanks!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Which Action do you mean? If you mean my PHP Form Action <ActionsForge - The Complete Repository of Freeway Actions

then you are also writing your own form handler. So in that
handler, you would add some conditional logic. Let’s say that you had
three checkboxes: Parts, Service, and Corporate.

In your form handler, you would be looking for $_POST['parts'] (or
any other checkbox field) to either be there or not. Checkboxes are
simply not sent by the browser if they’re un-checked.

$to = array();
foreach($_POST as $k=>$v){
	switch($k){
		case 'parts':
		$to[] = 'email@hidden';
		break;
		case 'service':
		$to[] = 'email@hidden';
		break;
		case 'corporate':
		$to[] = 'email@hidden';
		break;
		default:
		break;
	}
}
$to = implode(',',$to);

This fragment of PHP loops through all of the form inputs, looking for
the field to be named either parts, service or corporate. If it finds
one or more such, it adds the appropriate recipient address to the $to
array. At the end, this array is converted to a string suitable for
use inside a Mail() function call as the first argument.

Now if you wanted the form to only send to one person or another, you
would not use checkboxes, but rather radio buttons. A radio button set
is sent as long as one option is selected, but you can only choose one
option. In that case, the value is what will be different:

$to = "";
if($_POST['attention']){
	switch ($_POST['attention']){
		case 'parts':
		$to = 'email@hidden';
		break;
		case 'service':
		$to = 'email@hidden';
		break;
		case 'corporate':
		$to = 'email@hidden';
		break;
		default:
		break;
	}
}
if(!empty($to)) Mail($to,$subject,$body,$headers,$flags);

Hope this helps,

Walter

On Feb 10, 2009, at 9:42 AM, paulvw wrote:

We have a form activated by PHP form action: a few items can be
ticked. Depending on what people tick the form need to be send to
different email addresses. Any idea how to do that?
Thanks!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Just a note: if you’re looking at this on the Web forum, each of the email addresses above are meant to be different from one another.

The forum software stripped them out so they wouldn’t get spammed.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Wow…wow… amazing…I can’t produce any PHP myself, but copy and paste is easy :slight_smile:
Thank you Walter! This is great. Another problem solved in tis complicated world.
Thanks again. I’ll be back i I have any further questions, but I think this explanation is more than suffcient!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Whoops… help… Walter… I didn’t succeed - bacause teh form is made with PHP Feedback Form - I always mix up the names. Any possibility to manipulate that one?

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Tim Plumb will have to advise you on that one, the fix (on the PHP side) would be similar, but since that PHP gets generated by the Action, you’re going to need to explore alternate ways of fixing this so you won’t overwrite your changes each time you publish.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Right, I got that. No problem. If you read this Tim, any suggestions?

Thanks!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’ve made a number of specific modifications to the action like this in the past
for various Freeway users (validation, CSV output, etc) but unfortunately I
don’t have the time at the moment to adjust and test the action to do this for
you.
My suggestion would be to have the action output code that is as close as you
want and then use this as the basis to manually adjust the code in a text
editor.
Walter’s code looks like it should do what you want and should be inserted into
the main feedback loop code.
Once you are happy with this you will need to remove the PHP Feeback Form action
from the page and manually target the form to the modified PHP page. This can be
uploaded with the form page using the Upload Stuff or Extra Resources actions.
Regards,
Tim.

Quoting paulvw email@hidden:

Right, I got that. No problem. If you read this Tim, any suggestions?

Thanks!

Paul


Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

OK Tim thanks. I’ll give it a try!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

One more question then. After adding the script, how do I: “you will need to remove the PHP Feeback Form action from the page and manually target the form to the modified PHP page”.
Removing is easy, but how do I manually target the the form to the modified PHP page?

Thanks in advance!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

In the Page / Form Setup dialog, change the “action” property to be the same as when the Action (big a) modified your site. To figure this out, look at your site in a browser while the Action is still applied, and view source. Look for the string <form action=… and copy whatever is in the quotation marks after action=. You will not need to add the quotation marks themselves, just whatever is inside them.

Once you remove the Action, the page will have to do this step because the Action was doing it for you. Adding it in to the Form Setup dialog will cause Freeway to write out this tag as it should be.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The PHP easiForm actions have been updated to v1.43b to include the option of letting the FW user have a form sent to different email address relative to form element selection.

Download:
http://www.actionsforge.com/projects/view/35-easiform

For Menu list selection:

  1. Simply add a menu list to your form, add various options as follows:

  2. Select the menu and give it a name in the Freeway inspector, lets say ‘department’
    without quotes.

  3. Add various options to the menu as follows:

Choice Value
Feedback feedback(at)somedomain dot com
Support support (at) somedomain d com
Jim jim (a) somedomain (dot) com
Alan alan_james at somedomain (d) com
  1. Now select ‘Yes’ from the ‘Use different recipients’ menu in the PHP easiForm action.

  2. In the ‘Recipients element’ field add the ‘exact’ name you called the menu, in
    this example it would be ‘department’ without quotes.

For Radio selection:

  1. Simply add the number of radio buttons to your form.

  2. Give all these radio buttons the same name.

  3. Set the value for ‘each’ radio selection to a relative email address, the following
    gives 4 radio buttons as an example.

Name Value
departmen feedback(at)somedomain dot com
department support (at) somedomain d com
department jim (a) somedomain (dot) com
department alan_james at somedomain (d) com
  1. Now select ‘Yes’ from the ‘Use different recipients’ menu in the PHP easiForm action.

  2. In the ‘Recipients element’ field add the ‘exact’ name you called the radio cluster, in
    this example it would be ‘department’ without quotes.

Upload the Freeway site and the form will be sent to the address relative to the selection of any of the above form element options.

The (a), (at), dot, d , (dot( etc. are not added by the list, this is how you could enter the email addresses in your form elements, PHP easiForm will swap the bits over to make them valid emails, see the Read me file that is downloaded with the action.

HTH


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Wow Mike, yu were able to fix it /add that to easiform. I’ll check it out.

Thanks!

Paul


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options