工作联系表格,但没有显示警报信息

时间:2016-03-24 14:39:17

标签: javascript jquery ajax phpmailer

这是我的网站:http://bbb.antalyabalikcilik.com.tr/contact-us.html

我有联系表格。我收到电子邮件到我的电子邮件地址,但电子邮件发送'谢谢你'提醒后,表格没有显示。

html代码:

<!-- contact form -->
<div class='grid_col grid_col_8'>
  <div class='ce clearfix'>
    <h3 class="ce_title">Drop us a line</h3>
    <div>
      <div role="form" class="cf" id="cf-f16-p10-o1" lang="en-US" dir="ltr">
        <div class="screen-reader-response"></div>
        <form action="email.php" method="post" class="cf-form contact-form" novalidate="novalidate">
         <p>Name*
           <br />
           <span class="cf-form-control-wrap your-name"><input type="text" name="name" value="" size="107" class="cf-form-control cf-text cf-validates-as-required" aria-required="true" aria-invalid="false" />
           </span>
         </p>
         <p>Email*
           <br />
           <span class="cf-form-control-wrap your-email"><input type="email" name="email" value="" size="107" class="cf-form-control cf-text cf-email cf-validates-as-required cf-validates-as-email" aria-required="true" aria-invalid="false" />
           </span>
         </p>
         <p>Message
           <br />
           <span class="cf-form-control-wrap your-message"><textarea name="message" cols="107" rows="8" class="cf-form-control cf-textarea" aria-invalid="false"></textarea>
           </span>
         </p>
         <p>                                     
           <input type="submit" value="Gönder" class="cf-form-control cf-submit" />
         </p>
         <div class="cws_msg_box error-box clearfix">
           <div class="icon_section"><i class="fa fa-exclamation"></i></div>
             <div class="content_section">
               <div class="msg_box_title">Error box</div>
               <div class="msg_box_text"></div>
             </div>
           </div>
         </form>
         <div class="email_server_responce"></div>
       </div>
     </div>`enter code here`
   </div>
 </div>
 <!-- / conatct form -->

email.php

<?php

$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "mail.xxx.com.";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "xxx@xxx.com";  // SMTP username
$mail->Password = "123456789"; // SMTP password

$mail->From = "xxx@xxx.com";
$mail->FromName = "www.xxx.com";
$mail->AddAddress("xxx@hotmail.com");


$mail->WordWrap = 50;                                 // set word wrap to 50 characters

$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "received from website email";
$mail->Body    = $message;
$mail->AltBody = $message;

$content = '<div style="background: #eee; padding: 10px; font-size: 14px; font-family: comic sans ms">
İsim : '.$name.'<br />
Email : '.$email.'<br />
Mesaj : '.$message.'</div>';
$mail->MsgHTML($content);





if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

js code:

/* contact form */
if (jQuery(".contact-form").length) {
  /**/
  /* contact form */
  /**/

  /* validate the contact form fields */      
  jQuery(".contact-form").each(function(){

    jQuery(this).validate(  /*feedback-form*/{
        onkeyup: false,
        onfocusout: false,
        errorElement: 'p',
        errorLabelContainer: jQuery(this).find('.msg_box_text'),
        rules:
        {
          name:
          {
            required: true
          },
          email:
          {
            required: true,
            email: true
          },
          message:
          {
            required: true
          },
          verify: {
            required: true,
            remote: {
              url: 'php/check-capcha.php',
              type: "post",
              data:
              {
                  code: function()
                  { 
                      return jQuery('.verify').val();
                  }
              }
            }
          }
        },
        messages:
        {
          name:
          {
            required: 'Please enter your name',
          },
          email:
          {
            required: 'Please enter your email address',
            email: 'Please enter a VALID email address'
          },
          message:
          {
            required: 'Please enter your message'
          },
          verify: {
            required: 'Please enter Captcha',
            remote: "Please enter a VALID Captcha"
          }
        },
        invalidHandler: function()
        {
          jQuery(this).find(".cws_msg_box.error-box").slideDown('fast');
          jQuery("#feedback-form-success").slideUp('fast');

        },
        submitHandler: function(form)
        {   
          jQuery(form).find(".cws_msg_box.error-box").slideUp('fast'); 
          var $form = jQuery(form).ajaxSubmit();
          submit_handler($form, jQuery(form).parent().children(".email_server_responce") );
        }
      });
    })

  /* Ajax, Server response */ 
  var submit_handler =  function (form, wrapper){

    var $wrapper = jQuery(wrapper); //this class should be set in HTML code

    $wrapper.css("display","block");
    var data = {
      action: "email_server_responce",
      values: jQuery(form).serialize()
    };
    //send data to server
    jQuery.post("email.php", data, function(s_response) {
      s_response = jQuery.parseJSON(s_response);
      if(s_response.info == 'success'){
        $wrapper.addClass("message message-success").append('<div class="cws_msg_box success-box clearfix"><div class="icon_section"><i class="fa fa-thumbs-up"></i></div><div class="content_section"><div class="msg_box_title">Success!</div><div class="msg_box_text">Your message was successfully delivered.</div></div></div>');
        $wrapper.delay(5000).hide(500, function(){
          jQuery(this).removeClass("message message-success").text("").fadeIn(500);
          $wrapper.css("display","none");
        });
        jQuery(form)[0].reset(); 
      } else { 
        $wrapper.addClass("cws_msg_box error-box clearfix").append("<div class='icon_section'><i class='fa fa-exclamation'></i></div><div class='content_section'><div class='msg_box_title'>Server fail!</div><div class='msg_box_text'><p> Please try again later!</p></div></div>");
        $wrapper.delay(5000).hide(500, function(){
          jQuery(this).removeClass("cws_msg_box error-box clearfix").text("").fadeIn(500);
          $wrapper.css("display","none");
        });
      }
    });
  return false;
  }
}

/**/

出了什么问题?请帮帮我......

0 个答案:

没有答案