close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Variable to control $recipientEmail

Thread began 3/16/2010 6:32 pm by leifbaker378532 | Last modified 3/25/2010 7:40 pm by Jimmy Wu | 1246 views | 9 replies |

leifbaker378532

Variable to control $recipientEmail

Hi,
Your extensions work great. I have built a simple submission form requiring name, email address and a location from a dropdown menu (a US state: strcmp). I would like to send the completed form to a different recipient depending on which state(s) are chosen - as if to different sales reps in different regions.

Can anyone tell me how to correctly do this? I think I know how conceptually, but I can't get the syntax right.

Any help will be appreciated.

Thanks,
Leif Baker

Sign in to reply to this post

Jimmy Wu

What do you have so far for setting this up? You will want to set the $RecipientEmail to be different based on the different state. How is the state set up? Is it from a form and is the form's method post?

Sign in to reply to this post

leifbaker378532

It's a POST

Now the recipient is :
_______________________________________________________________
if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST))) {
//WA Universal Email object="mail"
//Send Loop Once Per Entry
$RecipientEmail = "leifbaker@nj.rr.com";include("WA_Universal_Email/WAUE_forms_1.php");
_______________________________________________________________________

while the states come from a drop down list, like here:
__________________________________________________________________________
<option value="AL" <?php if (!(strcmp("AL", (isset($_GET["invalid"])?ValidatedField("forms","Contact_me_group_State"):"")))) {echo "selected=\"selected\"";} ?>>Alabama</option>
__________________________________________________________________________

I've included the form page as a PDF file.
Any help you can give me will be appreciated.

Thank you,
Leif Baker

Attached Files
forms.pdf
Sign in to reply to this post

Jimmy Wu

Ok, so you will want to have an switch statement based on the post value of the drop down list. Basically you'd want to set up a switch statement:
control-structures.switch.php

php:
switch((isset($_POST["select"]))?$_POST["select"]:"") {

  case "AL":
    $RecipientEmail =  "leifbaker@nj.rr.com";include("WA_Universal_Email/WAUE_forms_1.php");
    break;
}



You would want a different case for each of the states.

Sign in to reply to this post

leifbaker378532

Thanks, but ...

... i"m afraid I still can't get it to work

I tried like this -
________________________________________

if ((($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST))) {
//WA Universal Email object="mail"
//Send Loop Once Per Entry
//$RecipientEmail = "leifbaker64@hotmail.com";include("WA_Universal_Email/WAUE_forms_1.php");

switch((isset($_POST["select"]))?$_POST["select"]:"") {
case "AL":
$RecipientEmail = "leifbaker@nj.rr.com";include("WA_Universal_Email/WAUE_forms_1.php");
break;
case "AK":
$RecipientEmail = "leifbaker64@hotmail.com";include("WA_Universal_Email/WAUE_forms_1.php");
break;
case "AZ":
$RecipientEmail = "leifbaker64@yahoo.com";include("WA_Universal_Email/WAUE_forms_1.php");
break;
}

//Send Mail All Entries
if (""!="") {
header("Location: ");
}
}

______________________________________________________

but that didn't work.
I tried a couple other ways, also , with equal results (none).

Can you tell me exactly how I should set this switch up?

Thanks,
Leif Baker

Sign in to reply to this post

Jimmy Wu

Its possible that the select list value isn't being populated correctly or we're not reading it correctly. Try putting this above the code switch code:
die((isset($_POST["select"]))?$_POST["select"]:"not set");

this will cause the select list value to be output when the form is run.

Sign in to reply to this post

leifbaker378532

Thanks, but that's not it

That merely makes the page return "not set".
I made a simpler version of the form. I've attached it as a PDF.

There's got to be a simple way to do this that we're overlooking.
It's probably a syntax error on my part.
I didn't think it would be so complicated. But I'm grateful for you efforts.

Any help you or anyone can give me will be greatly appreciated.

Thanks again,
Leif Baker

Attached Files
form.pdf
Sign in to reply to this post

Jimmy Wu

Sorry, I think the first time I sent you the code, I looked at the wrong form, so I sent you the wrong code. The select list name is "Contact_me_group_State", so you'd want to get the post variable with that, not the "select" post variable. That is why the variable is not set.

In the switch statement, try using this instead:

php:
switch((isset($_POST["Contact_me_group_State"]))?$_POST["Contact_me_group_State"]:"") {



You can take out the testing code I sent you earlier:

php:
die((isset($_POST["select"]))?$_POST["select"]:"not set");
Sign in to reply to this post

leifbaker378532

You da man...

that did it.
Thanks for all your help.

Sign in to reply to this post

Jimmy Wu

Great to hear it. If you run into any additional issues, feel free to open a new thread.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...