Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PHP联系人表单问题(不允许使用方法)_Javascript_Php_Html_Email_Contact - Fatal编程技术网

Javascript PHP联系人表单问题(不允许使用方法)

Javascript PHP联系人表单问题(不允许使用方法),javascript,php,html,email,contact,Javascript,Php,Html,Email,Contact,PHP代码 $name_error = $email_error = ""; $name = $email = $message = $success = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $name_error = "Name is required"; } else { $name = test_input($_POST["name"]);

PHP代码
$name_error = $email_error =  "";
$name = $email = $message = $success = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["name"])) {
    $name_error = "Name is required";
  } else {
    $name = test_input($_POST["name"]);
    if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
      $name_error = "Only letters and white space allowed"; 
    }
  }

  if (empty($_POST["email"])) {
    $email_error = "Email is required";
  } else {
    $email = test_input($_POST["email"]);
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
      $email_error = "Invalid email format"; 
    }
  }

    if (empty($_POST["subject"])) {
    $subject_error = "Subject is required";
  } else {
    $subject = test_input($_POST["subject"]);
  }

  if (empty($_POST["message"])) {
    $message = "";
  } else {
    $message = test_input($_POST["message"]);
  }

  $to = "ayoub.kermout@gmail.com"
  $about = "GA:TC CONTACT RECIVED!!"
  $body = "Name: $name\nEmail: $email\nSubject: $subject\nMessage: $message"

  mail($to, $about, body, "From: $name <$email>")
  $success = "Message sent, thank you for contacting us!";
  $name = $email = $message = '';

}
}
?>
$name\u error=$email\u error=”“;
$name=$email=$message=$success=“”;
如果($\服务器[“请求\方法”]=“发布”){
如果(空($_POST[“name”])){
$name\u error=“名称是必需的”;
}否则{
$name=test_输入($_POST[“name”]);
如果(!preg_match(“/^[a-zA-Z]*$/”,$name)){
$name_error=“仅允许字母和空格”;
}
}
如果(空($_POST[“email”])){
$email\u error=“需要电子邮件”;
}否则{
$email=test_输入($_POST[“email”]);
如果(!filter_var($email,filter_VALIDATE_email)){
$email\u error=“无效的电子邮件格式”;
}
}
if(空($_POST[“主题”])){
$subject\u error=“subject是必需的”;
}否则{
$subject=test_输入($_POST[“subject”]);
}
如果(空($_POST[“message”])){
$message=“”;
}否则{
$message=test_输入($_POST[“message”]);
}
$to=“ayoub。kermout@gmail.com"
$about=“GA:TC联系人已收到!!”
$body=“Name:$Name\nEmail:$email\n对象:$subject\n消息:$message”
邮件($to$about,正文,“发件人:$name”)
$success=“已发送消息,感谢您与我们联系!”;
$name=$email=$message='';
}
}
?>
JAVASCRIPT代码

(function($) {
  "use strict"; // Start of use strict

  // Smooth scrolling using jQuery easing
  $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      if (target.length) {
        $('html, body').animate({
          scrollTop: (target.offset().top - 48)
        }, 1000, "easeInOutExpo");
        return false;
      }
    }
  });

  // Closes responsive menu when a scroll trigger link is clicked
  $('.js-scroll-trigger').click(function() {
    $('.navbar-collapse').collapse('hide');
  });

  // Activate scrollspy to add active class to navbar items on scroll
  $('body').scrollspy({
    target: '#mainNav',
    offset: 48
  });

  // Collapse the navbar when page is scrolled
  $(window).scroll(function() {
    if ($("#mainNav").offset().top > 100) {
      $("#mainNav").addClass("navbar-shrink");
    } else {
      $("#mainNav").removeClass("navbar-shrink");
    }
  });

  // Scroll reveal calls
  window.sr = ScrollReveal();
  sr.reveal('.sr-icons', {
    duration: 600,
    scale: 0.3,
    distance: '0px'
  }, 200);
  sr.reveal('.sr-button', {
    duration: 1000,
    delay: 200
  });
  sr.reveal('.sr-contact', {
    duration: 600,
    scale: 0.3,
    distance: '0px'
  }, 300);

  // Magnific popup calls
  $('.popup-gallery').magnificPopup({
    delegate: 'a',
    type: 'image',
    tLoading: 'Loading image #%curr%...',
    mainClass: 'mfp-img-mobile',
    gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0, 1]
    },
    image: {
      tError: '<a href="%url%">The image #%curr%</a> could not be loaded.'
    }
  });

})(jQuery);
<div class="container">
      <div class="row">
          <div class="col-lg-8 mx-auto text-center">
              <h2 class="section-heading text-white">CONTACT FORM</h2>
              <hr class="light">
              <p class="text-faded">Fill the form table down below to contact us.</p>
          </div>
      </div>
    </div>
<div class="container">
  <div class="row">
      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">                        
        <h2>Contact</h2>
      </div>
  </div>
  <div class="row">
      <div class="col-lg-8 col-md-10 mx-auto">
          <form id="contact-form" class="form" action="mail/contact.php" method="post" role="form">
              <div class="form-group">
                  <label class="form-label" for="name">Your Name</label>
                  <input type="text" class="form-control" id="name" name="name" placeholder="Your name" tabindex="1" required>
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="email">Your Email</label>
                  <input type="email" class="form-control" id="email" name="email" placeholder="Your Email" tabindex="2" required>
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="subject">Subject</label>
                  <input type="text" class="form-control" id="subject" name="subject" placeholder="Subject" tabindex="3">
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="message">Message</label>
                  <textarea rows="5" cols="50" name="message" class="form-control" id="message" placeholder="Message..." tabindex="4" required></textarea>                                 
              </div>
              <div class="text-center">
                  <button type="submit" class="btn btn-start-order">Send Message</button>
              </div>
          </form>
      </div>
  </div>
</div>
(函数($){
“使用严格”;//开始使用严格
//使用jQuery平滑滚动
$('a.js-scroll-trigger[href*=“#”]:不是([href=“#”])。单击(函数(){
if(location.pathname.replace(/^\/,'')==this.pathname.replace(/^\/,'')和&location.hostname==this.hostname){
var target=$(this.hash);
target=target.length?target:$('[name='+this.hash.slice(1)+']');
if(目标长度){
$('html,body')。设置动画({
scrollTop:(target.offset().top-48)
},1000,“easeInOutExpo”);
返回false;
}
}
});
//单击滚动触发链接时关闭响应菜单
$('.js滚动触发器')。单击(函数(){
$('.navbar collapse')。collapse('hide');
});
//激活scrollspy以将活动类添加到滚动条上的导航栏项目
$('body').scrollspy({
目标:“#主导航”,
抵销:48
});
//滚动页面时折叠导航栏
$(窗口)。滚动(函数(){
如果($(“#mainNav”).offset().top>100){
$(“#主导航”).addClass(“导航条收缩”);
}否则{
$(“#主导航”).removeClass(“导航条收缩”);
}
});
//滚动显示通话
window.sr=ScrollReveal();
高级显示(“.sr图标”{
持续时间:600,
比例:0.3,
距离:“0px”
}, 200);
高级侧窗(“.sr按钮”{
持续时间:1000,
延误:200
});
高级分隔缝(“.sr触点”{
持续时间:600,
比例:0.3,
距离:“0px”
}, 300);
//放大弹出调用
$('.popup gallery').magnificPopup({
代表:“a”,
键入:“图像”,
t加载:“正在加载图像#%curr%…”,
mainClass:'mfp img mobile',
画廊:{
启用:对,
NavigateByMgClick:true,
预加载:[0,1]
},
图片:{
恐怖:“无法加载。”
}
});
})(jQuery);
HTML代码

(function($) {
  "use strict"; // Start of use strict

  // Smooth scrolling using jQuery easing
  $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      if (target.length) {
        $('html, body').animate({
          scrollTop: (target.offset().top - 48)
        }, 1000, "easeInOutExpo");
        return false;
      }
    }
  });

  // Closes responsive menu when a scroll trigger link is clicked
  $('.js-scroll-trigger').click(function() {
    $('.navbar-collapse').collapse('hide');
  });

  // Activate scrollspy to add active class to navbar items on scroll
  $('body').scrollspy({
    target: '#mainNav',
    offset: 48
  });

  // Collapse the navbar when page is scrolled
  $(window).scroll(function() {
    if ($("#mainNav").offset().top > 100) {
      $("#mainNav").addClass("navbar-shrink");
    } else {
      $("#mainNav").removeClass("navbar-shrink");
    }
  });

  // Scroll reveal calls
  window.sr = ScrollReveal();
  sr.reveal('.sr-icons', {
    duration: 600,
    scale: 0.3,
    distance: '0px'
  }, 200);
  sr.reveal('.sr-button', {
    duration: 1000,
    delay: 200
  });
  sr.reveal('.sr-contact', {
    duration: 600,
    scale: 0.3,
    distance: '0px'
  }, 300);

  // Magnific popup calls
  $('.popup-gallery').magnificPopup({
    delegate: 'a',
    type: 'image',
    tLoading: 'Loading image #%curr%...',
    mainClass: 'mfp-img-mobile',
    gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0, 1]
    },
    image: {
      tError: '<a href="%url%">The image #%curr%</a> could not be loaded.'
    }
  });

})(jQuery);
<div class="container">
      <div class="row">
          <div class="col-lg-8 mx-auto text-center">
              <h2 class="section-heading text-white">CONTACT FORM</h2>
              <hr class="light">
              <p class="text-faded">Fill the form table down below to contact us.</p>
          </div>
      </div>
    </div>
<div class="container">
  <div class="row">
      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">                        
        <h2>Contact</h2>
      </div>
  </div>
  <div class="row">
      <div class="col-lg-8 col-md-10 mx-auto">
          <form id="contact-form" class="form" action="mail/contact.php" method="post" role="form">
              <div class="form-group">
                  <label class="form-label" for="name">Your Name</label>
                  <input type="text" class="form-control" id="name" name="name" placeholder="Your name" tabindex="1" required>
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="email">Your Email</label>
                  <input type="email" class="form-control" id="email" name="email" placeholder="Your Email" tabindex="2" required>
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="subject">Subject</label>
                  <input type="text" class="form-control" id="subject" name="subject" placeholder="Subject" tabindex="3">
              </div>                            
              <div class="form-group">
                  <label class="form-label" for="message">Message</label>
                  <textarea rows="5" cols="50" name="message" class="form-control" id="message" placeholder="Message..." tabindex="4" required></textarea>                                 
              </div>
              <div class="text-center">
                  <button type="submit" class="btn btn-start-order">Send Message</button>
              </div>
          </form>
      </div>
  </div>
</div>

联系方式

填写下表与我们联系

接触 你的名字 你的电子邮件 主题 消息 发送消息
问题: 正如您所看到的,我的PHP、JS、HTML代码用于联系人表单,但由于某些原因,它不起作用!!?? 每次我尝试使用它,我总是得到(方法不允许)!!!?? 我几乎什么都试过了(新的PHP代码和不同的html代码)
请注意(我在glitch上的一个网站上使用它),它并不正式支持PHP,但它确实支持。除了在
mail($to,$about,body,“From:$name”)中应该是
body
而不是
body
之外,它应该可以工作

因此,问题应该来自主机提供商


顺便说一句:Gmail似乎有更严格的安全政策。我在Gmail上失败,尝试了另一种邮件服务,并成功地收到了电子邮件。

这不是重现问题所需的最低代码。请尝试重新询问您的问题。好的,我将尝试使用hotmail或yahoo,如果不起作用,我将使用其他主机。(用于快速响应的THNAK)