Привет, вобщем проблема в том, что после отправки формой через ПХП функцию письма, на почту приходит сразу два письма, немогу никак решить данную проблему, может кто может помочь?
вот сам скрипт:
PHP |
$to = 'моймайл@msn.com';
//Localization //For English Language
$name_loc = 'Name: '; $contact_mail_loc = 'Contact email: '; $conatct_phone_loc = 'Contact Phone: '; $message_loc = 'Message: ';
$ok_loc = 'Ok'; $required_loc = 'This field is required!'; $email_loc ='Please enter valid email address, example: nimi@mail.ee';
$thanks_msg = 'Thank You <b><?=$name;?></b>!<br /> We contact with you As soon as possible.'; $error_msg = 'Sorry <b><?=$name;?></b>, your message is not sent, please try again later!';
$submit_loc = 'Send';
$subject_loc = 'Contact Form';
//User info (DO NOT EDIT!) $name = stripslashes($_POST['name']); //sender's name $email = stripslashes($_POST['Email']); //sender's email $phone = stripslashes($_POST['Phone']); //sender's phone
//The subject
$subject = $subject_loc; // the subject //$subject = '=?koi8-r?B?'.base64_encode(convert_cyr_string($subject, "w","k")).'?=';
$headers = "Content-type: text/plain; charset=utf-8 \r\n"; $headers .= "From: ".$name." <".$email.">\r\n"; $headers .= "Reply-To: ".$email."\r\n"; $headers .= "Return-Path: ".$email;
//The message you will receive in your mailbox //Each parts are commented to help you understand what it does exaclty. //YOU DON'T NEED TO EDIT IT BELOW BUT IF YOU DO, DO IT WITH CAUTION!
$msg = "---Message--- \r\n"; //add subject to the message (optional! It will be displayed in the header anyway)
$msg .= $name_loc.$name. "\r\n"; $msg .= $contact_mail_loc.$email. "\r\n"; if ($phone != " "){ $msg .= $conatct_phone_loc. $phone." \r\n"; //add sender's phone }
$msg .= $message_loc.stripslashes($_POST['mess'])."\r\n\n\n\n"; //the message itself
//Extras: User info (Optional!) //Delete this part if you don't need it //Display user information such as Ip address and browsers information... $msg .= "---User information--- \r\n"; //Title $msg .= "User IP : ".$_SERVER["REMOTE_ADDR"]."\r\n"; //Sender's IP $msg .= "Browser info : ".$_SERVER["HTTP_USER_AGENT"]."\r\n"; //User agent //$msg .= "User come from : ".$_SERVER["HTTP_REFERER"]; //Referrer // END Extras
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/jаvаscript"> <!-- function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
return true; } //--> </SCRIPT>
<script type="text/jаvаscript" src="js/livevalidation_standalone.compressed.js"></script>
</head> <body> '; if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $self = $_SERVER['PHP_SELF']; echo '
<table width="100%" cellpadding="2" cellspacing="0" class="tbmain"> <tr><td class="topleft" width="10" height="10"> </td> <td class="topmid"> </td> <td class="topright" width="10" height="10"> </td> </tr> <tr> <td class="midleft" width="10"> </td> <td class="midmid" valign="top"> <form action="" method="post" name="q_form_83373627278"> <input type="hidden" name="formID" value="83373627278" /> <div id="main"> <div class="pagebreak"> <table width="520" cellpadding="5" cellspacing="0"> <tr > <td width="150" class="left" > <label >'.$name_loc.'<span class="required">*</span></label> </td> <td class="right" > <input name="name" id="sayHello" size="20" type="text" class="text" value="" maxlength="100" /> <script type="text/jаvаscript"> var sayHello = new LiveValidation(\'sayHello\', { validMessage: "'.$ok_loc.'", wait: 500}); sayHello.add(Validate.Presence, {failureMessage: "'.$required_loc.'"}); </script> </td> </tr> <tr > <td width="150" class="left" > <label >'.$contact_mail_loc.'<span class="required">*</span></label> </td> <td class="right" > <input type="text" size="20" name="Email" class="text" value="" id="email" maxlength="100" /> <script type="text/jаvаscript"> var f20 = new LiveValidation(\'email\', { validMessage: "'.$ok_loc.'", wait: 500}); f20.add( Validate.Email, {failureMessage: "'.$email_loc.'"}); f20.add( Validate.Presence, {failureMessage: "'.$required_loc.'"}); </script> </td> </tr> <tr > <td width="150" class="left" > <label >'.$conatct_phone_loc.'<span class="required">*</span></label> </td> <td class="right" > <input type="text" size="20" name="Phone" class="text" value="" id="q2" onkeypress="return isNumberKey(event)" /> <script type="text/jаvаscript"> var phonef = new LiveValidation(\'q2\', { validMessage: "'.$ok_loc.'", wait: 500}); phonef.add( Validate.Presence, {failureMessage: "'.$required_loc.'"}); </script> </td> </tr> <tr > <td width="150" class="left" valign="top" > <label>'.$message_loc.'<span class="required">*</span></label> </td> <td class="right" > <textarea cols="60" rows="5" name="mess" class="text" id="q6" ></textarea> <script type="text/jаvаscript"> var mess = new LiveValidation(\'q6\', { validMessage: "'.$ok_loc.'", wait: 500}); mess.add(Validate.Presence, {failureMessage: "\n'.$required_loc.'"}); </script> </td> </tr> <tr > <td width="150" class="left" > </td> <td class="right"> <input type="submit" class="btn" value="'.$submit_loc.'" /> </td> </tr> </table> </div> </div> </form> </td> <td class="midright" width="10"> </td> </tr> <tr> <td class="bottomleft" width="10" height="10"> </td> <td class="bottommid"> </td> <td class="bottomright" width="10" height="10"> </td> </tr> </table> '; } else { error_reporting(0);
if (mail($to, $subject, $msg, $headers))
//Message sent! //It the message that will be displayed when the user click the sumbit button //You can modify the text if you want echo "<div class=\"MsgSent\"> ".$thanks_msg." </div>";
else
// Display error message if the message failed to send echo " <div class=\"MsgError\"> ".$thanks_msg." </div>"; }
echo ' </body> </html>'; |
испоьзую
livevalidation_standalone.compressed.js скрипт для валидации формы, после отправки на почту приходит два письма

Вот настройики
php на сервере
info.phpЗаранее Благодарен,
Дмитрий