+ Reply to Thread
Results 1 to 9 of 9

Thread: Changing submit to email based on selection
      
   

  1. #1
    jacobhebert's Avatar
    jacobhebert is offline Staff Sergeant
    Join Date
    Jan 2008
    Posts
    44

    Default Changing submit to email based on selection

    Hello,

    I have created a loan application form for a financial company, and I am trying to figure out how to set it up so that the email address that the form is submitted to, changes based on the location they choose from a drop down menu. Is this possible?

    I have uploaded the basic form to a blank page here in case that helps.

    Also, I was wondering if anyone knows how to make a checkbox a required field? Thanks so much in advance!

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: Changing submit to email based on selection

    Quite possible. Call your drop down "mailto" and in the standard script, replace this line:

    $mailto = youremail@yourdomain.com;

    with

    $mailto = $_POST['mailto'];


    However, please note that unless you embedd some protection measures, such a form can be easily exploited by spammers to send spam.

    It would be preferable changing the script so that in anycase it will recieve the name (or something similar) of the reciever, and select the email address from a hardcoded list.

    To make your checkbox required:

    There are many ways to make a checkbox required, depends on how you want the error message given.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    jacobhebert's Avatar
    jacobhebert is offline Staff Sergeant
    Join Date
    Jan 2008
    Posts
    44

    Default Re: Changing submit to email based on selection

    You are awesome, that worked great!

    So if I just set the value of each selection to the corresponding email address, spammer's are able to exploit the form although they can't actually see the email addresses? If so do you know where I could find a tutorial on setting up a hardcoded reference list?

    Thanks again.

    Jacob

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: Changing submit to email based on selection

    Yes, because this means that your script will accept ANY email address that are passed. Of course, security is more than that, however, this is what you need to do:

    1. Name the dropdown "mailto"
    2. Give values like 1,2,3,4 to the corresponding names
    3. Change your script with this:

    <?php
    $reciever = $_POST'mailto'];
    $email = $_POST['email'];
    switch ($reciever) {
    case "1":
    $mailto = "address1@yourdomain.com";
    break;
    case "2":
    $mailto = "address2@yourdomain.com";
    break;
    case "3":
    $mailto = "address2@yourdomain.com";
    break;
    case "4":
    $mailto = "address2@yourdomain.com";
    break;
    default:
    header("Location: errorpage.html"); // This line will send spammers to a errorpage
    exit;

    }

    if ($email == "") {
    $email = $mailto;
    }
    $mailsubj = "Type your mail subject here";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "Values submitted from web site form :\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    ?>

    Please note the existance of the error page: it will send to an error page spammers that will try to use your ACTION script to send spam, because the script will only accept the predefined email addresses . However, there are NO OTHER security measures here
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  5. #5
    jacobhebert's Avatar
    jacobhebert is offline Staff Sergeant
    Join Date
    Jan 2008
    Posts
    44

    Default Re: Changing submit to email based on selection

    First, thanks so much for your help with this, it would have taken me so long to research myself.

    I adjusted the action page and changed the values in the combobox and when I submit a form (or just try to load the action page) I get the following message:

    Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/application1.php:7) in /home/username/public_html/application1.php on line 136

    I probably left something out, or changed something I shouldn't have! If you need anymore information please feel free to email me at jacob@jacobhebert.com

    Thanks again!

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: Changing submit to email based on selection

    The above code must be pasted in the Start of Page of your page HTMl. Otherwise, if you have some other output to the screen before that, it will give you this error. Delete it from where you have it, and paste it in the Start of page. If there is still a problem, post again.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  7. #7
    jacobhebert's Avatar
    jacobhebert is offline Staff Sergeant
    Join Date
    Jan 2008
    Posts
    44

    Default Re: Changing submit to email based on selection

    Ok that was one problem, now when I submit, it takes me to the error page instead of the action page and doesn't send the email. I will paste the code thats in my application page to see if you can see what I most assuredly did wrong.

    <?php
    $reciever = $_POST_['mailto'];
    $email = $_POST_['email'];
    switch ($reciever) {
    case "1":
    $mailto = "aaaa@222financialservices.com";
    break;
    case "2":
    $mailto = "bbbb@222financialservices.com";
    break;
    case "3":
    $mailto = "cccc@222financialservices.com";
    break;
    case "4":
    $mailto = "dddd@222financialservices.com";
    break;
    case "5":
    $mailto = "eeee@222financialservices.com";
    break;
    case "6":
    $mailto = "ffff@222inancialservices.com";
    break;
    case "7":
    $mailto = "gggg@222financialservices.com";
    break;
    case "8":
    $mailto = "hhhh@222financialservices.com";
    break;
    case "9":
    $mailto = "iiii@222financialservices.com";
    break;
    case "10":
    $mailto = "jjjj@222financialservices.com";
    break;
    case "11":
    $mailto = "kkkk@222financialservices.com";
    break;
    case "12":
    $mailto = "llll@222financialservices.com";
    break;
    case "13":
    $mailto = "mmmm@222financialservices.com";
    break;
    default:
    header("Location: errorpage.html"); // This line will send spammers to an errorpage
    exit;

    }

    if ($email == "") {
    $email = $mailto;
    }
    $mailsubj = "Credit Application";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "The following values were submitted from the TJD website:\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    ?>

  8. #8
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: Changing submit to email based on selection

    Sorry,

    my mistake, should be $_POST['mailto'] and $_POST['email'] no underscore between POST and [
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  9. #9
    jacobhebert's Avatar
    jacobhebert is offline Staff Sergeant
    Join Date
    Jan 2008
    Posts
    44

    Default Re: Changing submit to email based on selection

    Like a charm. Thanks again buddy.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49