Здравствуйте. Помогите исправить форму. Все работает, но сообщение на почту не приходит. Вот форма. Код | <!-- Contact Form --> <form action="php/contactform.php" id="contact-form" method="post"> <div class="contact_form"> <div class="input-field"> <input id="first_name" type="email" name="contact-name"> <label for="first_name">Введите имя</label> </div> <div class="input-field"> <input id="contact_email" type="email" name="contact-email"> <label for="contact_email">Email адрес</label> </div> <div class="input-field"> <textarea class="materialize-textarea" name="contact-message"></textarea> <label>Введите сообщение</label> </div> </div> <button class="btn waves-effect waves-light" type="submit" name="action">Отправить</button> </form> <!-- //Contact Form -->
|
а это обработчик. Код | <?php
// basic settings section
$sendto = '[email protected]';
$subject = 'Заявка с сайта кондиционеров'; $iserrormessage = 'Ваше сообщение не отправлено, попробуйте ещё раз:'; $thanks = "Благодарим Вас за обращение! Мы свяжемся с Вами в ближайшее время.";
$emptyname = 'Пожалуйста введите email.'; $emptyemail = 'Не правильный email.'; $emptymessage = 'Пожалуйста,введите сообщение.';
$alertname = 'Неправельный формат имени. Пожалуйста, не используйте в имени специальные символы.'; $alertemail = 'Неправельный email , proper format is: [email protected]'; $alertmessage = "Please do not use special characters in your message. Standard url's should work fine.";
$alert = ''; $iserror = 0;
// cleaning the post variables function clean_var($variable) {$variable = strip_tags(stripslashes(trim(rtrim($variable))));return $variable;}
// validation of filled form if ( empty($_REQUEST['contact-name']) || $_REQUEST['contact-name'] == "") { $iserror = 1; $alert .= "<li><h6>" . $emptyname . "</h6></li>"; } elseif ( preg_match( "/[][{}()*+?.\\^$|]/i", $_REQUEST['contact-name'] ) ) { $iserror = 1; $alert .= "<li><h6>" . $alertname . "</h6></li>"; }
if ( empty($_REQUEST['contact-email']) || $_REQUEST['contact-email'] == "Enter your e-mail address") { $iserror = 1; $alert .= "<li><h6>" . $emptyemail . "</h6></li>"; } elseif ( !preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i", $_REQUEST['contact-email']) ) { $iserror = 1; $alert .= "<li><h6>" . $alertemail . "</h6></li>"; }
if ( empty($_REQUEST['contact-message']) || $_REQUEST['contact-message'] == "Your message goes here...") { $iserror = 1; $alert .= "<li><h6>" . $emptymessage . "</h6></li>"; } elseif ( preg_match( "/[][{}()*+?\\^$|]/i", $_REQUEST['contact-message'] ) ) { $iserror = 1; $alert .= "<li><h6>" . $alertmessage . "</h6></li>"; }
// if there was error, print alert message if ( $iserror==1 ) {
echo "<script> $(\"#message\").addClass(\"warning\").stop().slideDown(\"normal\").fadeIn(\"normal\").delay(3000).slideUp(\"normal\"); </script>"; echo "<div class=\"alert alert-block alert-danger\">"; echo "<div data-icon=\"\" class=\"alert_icon\"></div>"; echo "<div class=\"alert_title\"><h4>" . $iserrormessage . "</h4></div><br />"; echo "<ul class=\"unordered\">"; echo $alert; echo "</ul>"; echo "</div>";
} else { // if everything went fine, send e-mail $plsubject = "=?utf-8?B?".base64_encode($subject)."?="; $msg = "Name: " . clean_var($_REQUEST['contact-name']) . "\n"; $msg .= "E-mail: " . clean_var($_REQUEST['contact-email']) . "\n";
$msg .= "Message: \n\n" . clean_var($_REQUEST['contact-message']); $header = "Content-type: text/plain; charset=utf-8\r\n"; $header .= 'From:'. clean_var($_REQUEST['contact-email']);
mail($sendto, $plsubject, $msg, $header);
echo "<script>$(\"#message\").addClass(\"success\").stop().slideDown(\"normal\").fadeIn(\"normal\").delay(3000).slideUp(\"normal\");</script>"; echo "<div class=\"alert alert-block alert-success\">"; //echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><i class=\"icon-cross\"></i></button>"; echo "<div data-icon=\"\" class=\"alert_icon\"></div>"; echo "<h4>" . $thanks . "</h4>"; echo "</div>"; echo "<script>$('#contact-form input[type=text], #contact-form textarea').val('');</script>";
die(); } ?>
|
Помогите пожалуйста.
|