Привет всем! Может кто нибудь поможет? Есть сайт на вордпресс, не работает обратная связь Страница контактов PHP: <?php /* Template Name: Contact page */ get_header(); ?> <section id="content" class="nopadtop"> <?php if(iwebtheme_smof_data('map_enable') != 0) { ?> <div id="googlemaps" class="google-map"> </div> <?php } ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="col-lg-8 col-md-offset-77"> <div class="content_item"> <div class="form_settings"> <div class=" col-md-offset-77"> <h1 align="center"><?php the_title(); ?></h1> <h2 align="center"><?php echo __('Свяжитесь с нами, заполнив контактную форму','iwebtheme'); ?></h2> <form action="<?php the_permalink(); ?>" id="contactform" method="post" class="validateform"> <div class="row"> <p><input type="text" class="requiredField" name="contactName" id="contactName" placeholder="* <?php echo __('Введите ваше имя','iwebtheme'); ?>" data-rule="maxlen:4" data-msg="<?php echo __('Пожалуйста, введите не менее 4 символов','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><input type="text" class="requiredField" name="email" id="email" placeholder="* <?php echo __('Введите e-mail','iwebtheme'); ?>" data-rule="email" data-msg="<?php echo __('Не верный email адрес','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><input type="text" name="subject" id="subject" placeholder="<?php echo __('Введите тему','iwebtheme'); ?>" data-rule="maxlen:4" data-msg="<?php echo __('Пожалуйста, введите не менее 4 символов','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><textarea rows="12" name="comments" class="requiredField" id="comments" class="input-block-level" placeholder="* <?php echo __('Введите сообщение','iwebtheme'); ?>..." data-rule="required" data-msg="<?php echo __('Пожалуйста, напишите что-нибудь','iwebtheme'); ?>"></textarea> <div class="validation clearfix"> </div></p> <div class="col-lg-12 field"> <p> <button name="Mysubmitted" id="Mysubmitted" class="btn btn-theme margintop20 pull-left" type="submit"><?php echo __('Отправить','iwebtheme'); ?></button> <span class="pull-right margintop20">* <?php echo __('Пожалуйста, заполните все необходимые поля','iwebtheme'); ?>!</span> </p> <input type="hidden" name="submitted" id="submitted" value="true" /> <input type="hidden" name="contact_success" id="contact_success" value="<?php echo iwebtheme_smof_data('contact_success');?>" /> </div> </div> </form> </div> </div> </div> </form> </div> </div></div> </div> </div> </div> </section> <?php get_template_part('includes/contact-function'); ?> <?php get_footer(); ?> contact-function.php PHP: <?php global $redux_iwebtheme; $contact_email = $redux_iwebtheme['con-email']; $nameError =''; $emailError =''; $commentError = ''; //If the form is submitted if(isset($_POST['submitted'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactName']) === '') { $nameError = 'You forgot to enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['contactMail']) === '') { $emailError = 'You forgot to enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['contactMail']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['contactMail']); } //Check to make sure comments were entered if(trim($_POST['contactMessage']) === '') { $commentError = 'You forgot to enter your message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['contactMessage'])); } else { $comments = trim($_POST['contactMessage']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = $contact_email; $subject = "New message"; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nMessage: $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); if($sendCopy == true) { $subject = '[Copy] your submission'; $headers = 'From: '.$contact_email; wp_mail($email, $subject, $body, $headers); } $emailSent = true; } } ?> Чего не хватает?
Возможно, в скрипте ошибка, а сообщение об ошибке не видно. http://phpfaq.ru/debug как увидеть ошибки
Привет всем! Может кто нибудь поможет? Есть сайт на вордпресс, не работает обратная связь PHP: <?php /* Template Name: Contact page */ get_header(); ?> <section id="content" class="nopadtop"> <?php if(iwebtheme_smof_data('map_enable') != 0) { ?> <div id="googlemaps" class="google-map"> </div> <?php } ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="col-lg-8 col-md-offset-77"> <div class="content_item"> <div class="form_settings"> <div class=" col-md-offset-77"> <h1 align="center"><?php the_title(); ?></h1> <h2 align="center"><?php echo __('Свяжитесь с нами, заполнив контактную форму','iwebtheme'); ?></h2> <form action="<?php the_permalink(); ?>" id="contactform" method="post" class="validateform"> <div class="row"> <p><input type="text" class="requiredField" name="contactName" id="contactName" placeholder="* <?php echo __('Введите ваше имя','iwebtheme'); ?>" data-rule="maxlen:4" data-msg="<?php echo __('Пожалуйста, введите не менее 4 символов','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><input type="text" class="requiredField" name="email" id="email" placeholder="* <?php echo __('Введите e-mail','iwebtheme'); ?>" data-rule="email" data-msg="<?php echo __('Не верный email адрес','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><input type="text" name="subject" id="subject" placeholder="<?php echo __('Введите тему','iwebtheme'); ?>" data-rule="maxlen:4" data-msg="<?php echo __('Пожалуйста, введите не менее 4 символов','iwebtheme'); ?>" /> <div class="validation"> </div></p> <p><textarea rows="12" name="comments" class="requiredField" id="comments" class="input-block-level" placeholder="* <?php echo __('Введите сообщение','iwebtheme'); ?>..." data-rule="required" data-msg="<?php echo __('Пожалуйста, напишите что-нибудь','iwebtheme'); ?>"></textarea> <div class="validation clearfix"> </div></p> <div class="col-lg-12 field"> <p> <button name="Mysubmitted" id="Mysubmitted" class="btn btn-theme margintop20 pull-left" type="submit"><?php echo __('Отправить','iwebtheme'); ?></button> <span class="pull-right margintop20">* <?php echo __('Пожалуйста, заполните все необходимые поля','iwebtheme'); ?>!</span> </p> <input type="hidden" name="submitted" id="submitted" value="true" /> <input type="hidden" name="contact_success" id="contact_success" value="<?php echo iwebtheme_smof_data('contact_success');?>" /> </div> </div> </form> </div> </div> </div> </form> </div> </div></div> </div> </div> </div> </section> <?php get_template_part('includes/contact-function'); ?> <?php get_footer(); ?> contact-function.php PHP: <?php global $redux_iwebtheme; $contact_email = $redux_iwebtheme['con-email']; $nameError =''; $emailError =''; $commentError = ''; //If the form is submitted if(isset($_POST['submitted'])) { //Check to make sure that the name field is not empty if(trim($_POST['contactName']) === '') { $nameError = 'You forgot to enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['contactMail']) === '') { $emailError = 'You forgot to enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['contactMail']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['contactMail']); } //Check to make sure comments were entered if(trim($_POST['contactMessage']) === '') { $commentError = 'You forgot to enter your message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['contactMessage'])); } else { $comments = trim($_POST['contactMessage']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = $contact_email; $subject = "New message"; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nMessage: $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); if($sendCopy == true) { $subject = '[Copy] your submission'; $headers = 'From: '.$contact_email; wp_mail($email, $subject, $body, $headers); } $emailSent = true; } } ?> не отправляет письмо
Спасибо за отклик! Да, с платного хостинга, раньше работал, но только Яндекс почтой. Если Вам не сложно, помогите с ошибкой.
Должно быть что-то вроде этого: PHP: <?php if($_POST['send_email']){ $name_from = htmlspecialchars(trim($_POST['name'])); $from = htmlspecialchars(trim($_POST['email'])); $text_message = htmlspecialchars(trim($_POST['message'])); $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: ryf-tester@yandex.ru' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = 'ryf-tester@yandex.ru'; if($name_from != null && $text_message != null && $from != null){ $message = 'Сообщение от ' . $from .' ' . $text_message; mail($to, $name_from, $message, $headers); }else{ echo 'Вы не заполнили поле!'; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <form action="" method="post"> <input type="text" name="name" placeholder="Name"><br> <input type="text" name="email" placeholder="Email"> <br> <textarea name="message" placeholder="Message"></textarea><br> <input type="submit" value="Отправить" name="send_email"><br> </form> </body> </html> Это основная задумка. Дальше под себя подстраивайте. Если смог помочь - с вас лайк
Спасибо за помощь! Хотелось бы ошибку найти, а код тот же оставить, поможете хоть 10 лайков с поцелуем