Results 1 to 1 of 1

Thread: Web Form Generating 2 E-Mails

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

    Exclamation Web Form Generating 2 E-Mails

    I have a new web form that I am testing, and I am getting two e-mails every time the form is submitted. Can someone please take a look at my PHP code to see if there's something in there that's causing the double e-mail? Thank you.

    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;
      }
    }
       
    ?>
    Actually, I am getting three e-mails.

    The form is located here: http://www.financialaidfiler.com/Form/Form-Page.html
    Last edited by jscheuer1; 11-06-2013 at 03:03 PM. Reason: merge posts

Similar Threads

  1. Replies: 11
    Last Post: 11-07-2013, 02:47 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, 11:33 PM
  3. automatically sending mails
    By hemi in forum PHP
    Replies: 0
    Last Post: 10-02-2009, 03:06 PM
  4. Formatting autoreply e-mails
    By marynorn in forum PHP
    Replies: 1
    Last Post: 02-09-2008, 03:16 AM
  5. Caution with PayPal e-mails.
    By tech_support in forum The lounge
    Replies: 15
    Last Post: 03-12-2007, 07:21 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
  •