Contact Form sending me two emails even though user clicks the send button once.

The contact form works fine but when the submit button is clicked (once) the form sends me two emails.

I have been doing research & it seems it may be the browsers that are sending the contact form out twice but
I can’t find any suggestions on how to stop them from doing this.

Any help is greatly appreciated!

You have to post the code

you probable wrote the mail() function inside a loop or something similar.

show us the codes

Sorry for not posting the code:

[php]

<?PHP //Gather up the information from the form. $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; $company = $_POST["company"]; $phone = $_POST["phone"]; $emailAddr = $_POST["emailAddr"]; $contactBy = $_POST["contactBy"]; $comments = $_POST["comments"]; //email assembly $addrTo = "[email protected]"; $subject = "Contact from..."; $body = "The following information was received by Me. \n\r"; $body = $body . "First Name:" . $firstName . "\n\r"; $body = $body . "Last Name:" . $lastName . "\n\r"; $body = $body . "Company:" . $company . "\n\r"; $body = $body . "Phone Number:" . $phone . "\n\r"; $body = $body . "Email:" . $emailAddr . "\n\r"; $body = $body . "Contact By:" . $contactBy . "\n\r"; $body = $body . "Comments:" . $comments . "\n\r"; //Send email using php mail() command. $SpamErrorMessage = "No Websites URLs permitted"; if (preg_match("/http:/i", "$firstName")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$lastName")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$emailAddr")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$comments")) {echo "$SpamErrorMessage"; exit();} if (mail($addrTo, $subject, $body) == false) { echo "The email was not sent, please try again later."; } //send the users email. if (mail($addrTo, $subject, $body) == false) { echo "The email response was not sent. Please notify the webmaster."; } else { //echo the message on the web page. echo "We look forward to contacting you soon!"; } ?>

[/php]

well you did called mail function twice

i removed the extra call to mail() function for you
[php]

<?PHP //Gather up the information from the form. $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; $company = $_POST["company"]; $phone = $_POST["phone"]; $emailAddr = $_POST["emailAddr"]; $contactBy = $_POST["contactBy"]; $comments = $_POST["comments"]; //email assembly $addrTo = "[email protected]"; $subject = "Contact from..."; $body = "The following information was received by Me. \n\r"; $body = $body . "First Name:" . $firstName . "\n\r"; $body = $body . "Last Name:" . $lastName . "\n\r"; $body = $body . "Company:" . $company . "\n\r"; $body = $body . "Phone Number:" . $phone . "\n\r"; $body = $body . "Email:" . $emailAddr . "\n\r"; $body = $body . "Contact By:" . $contactBy . "\n\r"; $body = $body . "Comments:" . $comments . "\n\r"; //Send email using php mail() command. $SpamErrorMessage = "No Websites URLs permitted"; if (preg_match("/http:/i", "$firstName")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$lastName")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$emailAddr")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http:/i", "$comments")) {echo "$SpamErrorMessage"; exit();} //send the users email. if (mail($addrTo, $subject, $body) == false) { echo "The email response was not sent. Please notify the webmaster."; } else { //echo the message on the web page. echo "We look forward to contacting you soon!"; } ?>

[/php]

good luck

Yes it works, I really appreciate this!

Sponsor our Newsletter | Privacy Policy | Terms of Service