Bootstrap联系表单服务器无响应 [英] Bootstrap Contact Form server not responding

查看:84
本文介绍了Bootstrap联系表单服务器无响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使我的联系表正常工作,但是当我填写该表时,它抛出了服务器未响应的错误。

I am trying to get my contact form to work, but when I fill out the form, it throws out a server not responding error.

您可以在此处查看JSFiddle: JS& HTML联系人表单代码

You can view the JSFiddle here: JS & HTML contact form code

contact_me.php代码:

The contact_me.php code:

<?php

error_reporting(E_ALL); ini_set('display_errors', 1);

// check if fields passed are empty
if(empty($_POST['name'])        ||
   empty($_POST['email'])       ||
   empty($_POST['phone'])       ||
   empty($_POST['message'])     ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
    echo "No arguments Provided!";
    return false;
   }

$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

// create email body and send it    
$to = 'trisha@trishajohnson.net'; // put your email
$email_subject = "Contact form submitted by:  $name";
$email_body = "You have received a new message. \n\n".
                  " Here are the details:\n \nName: $name \n ".
                  "Email: $email_address\n Phone: $phone\n Message: \n $message";
$headers = "From: no-reply@trishajohnson.net\n";
$headers .= "Reply-To: $email_address"; 
mail($to,$email_subject,$email_body,$headers);
return true;            
?>

我在任何代码中都看不到任何错误,所以我不太确定问题是。

I don't see any errors in any of the code, so I'm not quite sure what the issue is.

推荐答案

当我访问您的页面时,我发现表单中缺少以下内容:

When I visited your page, I noticed the following were missing from the form:


  • 表单的操作。

  • 缺少名称元素。

解决方案:


  • 在表单内添加 method = post

  • 将name属性添加到输入中,即:< input type = text name = name>

  • Add method="post" inside the form.
  • Add the name attribute to the inputs, i.e.: <input type="text" name="name">

您的PHP包含POST变量,并且POST依赖name属性来处理表单数据。

Your PHP contains POST variables and POST relies on the name attribute in order to process the form's data.

Sidenote :您最初的问题不包含错误报告,该错误报告应用于检查错误。

Sidenote: Your original question did not contain the error reporting, which should be used to check for errors.

添加 错误报告 到文件顶部,这将有助于查找错误。

Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

侧注:错误报告仅应在登台中进行,而绝不能在生产中进行。

Sidenote: Error reporting should only be done in staging, and never production.

这篇关于Bootstrap联系表单服务器无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆