Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: My Web Form Sends 3 E-Mails Each Time (Please Help)

  1. #1
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation My Web Form Sends 3 E-Mails Each Time (Please Help)

    I'm sure it's an easy fix (because I have the whole thing running well), but, when I use the web form on my web-site, I get 3 e-mails every time there is a web form submission.

    Why is that? And, how can I make it so that I only get one?

    http://www.FinancialAidFiler.com/Form/Form-Page.html


    Thank you,
    Dan
    Last edited by jscheuer1; 11-06-2013 at 02:59 AM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,933
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Although it's possible this is a javascript problem, it probably is not. So the first thing you should do is determine if it is. The easiest way to do that would be to remove the javascript from the page. First make a backup copy of the page, just in case. Then get rid of:

    Code:
    <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>
    and:

    Code:
    <script language="JavaScript">
    // Code for validating the form
    // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
    // for details
    var frmvalidator  = new Validator("myemailform");
    frmvalidator.addValidation("name","req","Please provide your name"); 
    frmvalidator.addValidation("email","req","Please provide your e-mail address"); 
    frmvalidator.addValidation("email","email","Please enter a valid e-mail address"); 
    </script>
    Clear the browser cache and refresh the page. Then do a test. If you're still getting 3 emails, it's not the javascript. Most likely then it's server side code on or used by form-to-email.php.


    And by the way, this is going to be hard to help you with because we cannot test it directly. There's no way for us to know how many emails you're getting. And because we cannot easily see or test the server side code on or used by form-to-email.php.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks.

    Does anything look weird/funny in the "form-to-email.php" page?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,933
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Yes it's very funny. Sorry, just kidding. But that's what I was saying:

    we cannot easily see or test the server side code on or used by form-to-email.php
    First we cannot see it. If you could post the code, we could have a look at it. Second, even if we see it, it's not always clear what server side code is doing, it often relies upon other server side code not on that page. Servers can vary as well. What might cause an error on one might not on another.

    Before we get into any of that, please do as I suggested and determine if it's the javascript or not by removing the javascript and testing it without that to see if it still gives 3 emails.

    If it's not the javascript, please start a new thread in the PHP section and include the source code of the form-to-email.php file.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I tried what you said (removing the scripts), and I am still getting two e-mails. (One time I was getting three, but that may have been a fluke. I was typically getting two e-mails).

    What else can I try?
    Last edited by jscheuer1; 11-06-2013 at 02:16 PM. Reason: sense after removing a quote

  6. #6
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Oh, and here is the code from the PHP page:

    PHP Code:
    <?php
    if(!isset($_POST['submit']))
    {
        
    //This page should not be accessed directly. Need to submit the form.
        
    echo "error; you need to submit the form!";
    }
    $firstname $_POST['firstname'];
    $lastname $_POST['lastname'];
    $visitor_email $_POST['visitor_email'];
    $phone $_POST['phone'];
    $emailcheckbox $_POST['emailcheckbox'];
    $phonecheckbox $_POST['phonecheckbox'];
    $fafsacheckbox $_POST['fafsacheckbox'];
    $cssprofilecheckbox $_POST['cssprofilecheckbox'];
    $verificationcheckbox $_POST['verificationcheckbox'];
    $tapcheckbox $_POST['tapcheckbox'];
    $loanassistancecheckbox $_POST['loanassistancecheckbox'];
    $consultationcheckbox $_POST['consultationcheckbox'];
    $nassau $_POST['nassau'];
    $suffolk $_POST['suffolk'];
    $borough $_POST['borough'];
    $learn $_POST['learn'];
    $comments $_POST['comments'];

    //Validate first
    if(empty($firstname)||empty($visitor_email)) 
    {
        echo 
    "Name and e-mail address are mandatory!";
        exit;
    }

    if(
    IsInjected($visitor_email))
    {
        echo 
    "Bad email value!";
        exit;
    }

    $email_from 'Contact@FinancialAidFiler.com';//<== update the email address
    $email_subject "FinancialAidFiler.com E-Mail Inquiry";
    $email_body "Name: $firstname $lastname.\n".
    $email_visitor_email "E-Mail: $visitor_email.\n".
    $email_phone "Phone Number: $phone.\n".
    $email_emailcheckbox "Contact Preference: $emailcheckbox\n".
    $email_phonecheckbox "Contact Preference: $phonecheckbox.\n".
    $email_fafsacheckbox "Interested In: $fafsacheckbox.\n".
    $email_cssprofilecheckbox "Interested In: $cssprofilecheckbox.\n".
    $email_verificationcheckbox "Interested In: $verificationcheckbox.\n".
    $email_tapcheckbox "Interested In: $tapcheckbox.\n".
    $email_loanassistancecheckbox "Interested In: $loanassistancecheckbox.\n".
    $email_consultationcheckbox "Interested In: $consultationcheckbox.\n".
    $email_nassau "Nassau County: $nassau.\n".
    $email_suffolk "Suffolk County: $suffolk.\n".
    $email_borough "Borough: $borough.\n".
    $email_learn "How Did You Learn About Us?: $learn.\n".

    "Comments:\n $comments".
            
    $to "Contact@FinancialAidFiler.com";//<== update the email address
    $headers "From: $email_from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";
    //Send the email!
    mail($to,$email_subject,$email_body,$headers,$town);
    //done. redirect to ThankYou page.
    header('Location: ThankYou.html');


    // Function to validate against any email injection attempts
    function IsInjected($str)
    {
      
    $injections = array('(\n+)',
                  
    '(\r+)',
                  
    '(\t+)',
                  
    '(%0A+)',
                  
    '(%0D+)',
                  
    '(%08+)',
                  
    '(%09+)'
                  
    );
      
    $inject join('|'$injections);
      
    $inject "/$inject/i";
      if(
    preg_match($inject,$str))
        {
        return 
    true;
      }
      else
        {
        return 
    false;
      }
    }
       
    ?>

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,933
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    I'm not nearly as good with PHP as I am with javascript. But I don't see anything obvious there that would make it mail two times or more. Which is it exactly, 2 or 3? Or does it change, sometimes 2, sometimes 3? Is this with test emails that you send to yourself, or ones that users send? If it's only from users, they might be submitting the page more than once by mistake. If it's from tests of you emailing yourself, the only thing that strikes me is that there might be something wrong with the server. I have no idea for certain what that could be. My first thought was, maybe there are more than one mail() programs on the server, each in a different path, but all in the overall path of the server, and that they all fire at that command. The more I think about it, the more this seems reasonable. What kind of server is this that you're using? Who set it up? Who setup its mail program?

    Oh, and it just occurred to me, there wouldn't have to be more than one mail() program in the path. If there were more than one form-to-email.php in the path, the same thing could happen I suppose.
    Last edited by jscheuer1; 11-06-2013 at 03:08 PM. Reason: thought of another reason
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help.

    It seems to be three e-mails.

    These are all with test e-mails from me. It doesn't show somewhere in the code why it's e-mailing more than once?

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,933
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Not that I can tell. I mean there's only one mail() command. And it doesn't appear to be in any sort of loop. Who setup the server to handle mail? Is it possible that there are other copies of mail() around? Is it possible that there are other copies of form-to-email.php around?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    As John said, there's nothing there specifically that makes it send three times.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Replies: 0
    Last Post: 10-04-2010, 10:31 AM
  2. php script - display e-mails
    By mencel.net in forum Looking for such a script or service
    Replies: 6
    Last Post: 08-09-2010, 10:33 PM
  3. an e-card program that sends html emails
    By lrickyutah in forum Looking for such a script or service
    Replies: 0
    Last Post: 02-05-2010, 03:32 PM
  4. Caution with PayPal e-mails.
    By tech_support in forum The lounge
    Replies: 15
    Last Post: 03-12-2007, 06:21 AM
  5. About Menu and sending mails!
    By newpupil1 in forum HTML
    Replies: 8
    Last Post: 09-19-2005, 10:59 AM

Bookmarks

Posting Permissions

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