电子邮件中没有数据

时间:2015-08-20 04:31:19

标签: php html css

我已经创建了我的页面并且已经合并了一个表单。我相信我已经正确设置了所有内容,但是当我收到电子邮件时,没有显示任何输入数据?

jsFiddle附:https://jsfiddle.net/ebw2d9s5/1/

phpcode:

<?php 
if(isset($_POST['submit']))
{
    echo "Error: You need to Submit the Form!";
}

$to = "admin@hosting-mate.com"; // this is your Email address
$headers = "From:" . $from ;

$name = $_POST['name'];
$from = $_POST['email']; // this is the sender's Email address
$phone = $_POST['phone'];
$address = $_POST['address'];
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];

$subject = "DKS Online Quote Form";
$subject2 = "DKS Electrical and Data";

$response = "Mail Sent. Thank you " . $name . " for contacting us, we will be in contact with you shortly.";

mail($to,$subject,$message,$headers);
mail($from,$subject2,$response);

header('Location: ../index.php');
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
?>

以下是测试网站:http://www.hosting-mate.com/dkselectricalanddata/

编辑 - 这就是我的电子邮件中显示的内容:http://www.hosting-mate.com/dkselectricalanddata/_assets/img.png

提前致谢!   - 杰西

2 个答案:

答案 0 :(得分:1)

在尝试了很多不同的事情来弄清楚为什么我的数据永远不会出现在我的电子邮件中之后,我意识到实际上HTML文件并没有正确地发送数据。

对于可能使用数据表单遇到此问题的任何其他人,请勿使用:

enctype:"text/plain"

相反,请使用:

enctype:"multipart/form-data"

这样可以阻止您的电子邮件只显示标题而不显示输入数据。

感谢所有尝试帮助解决此问题的人。

答案 1 :(得分:0)

试试这个...

<?php 
if(isset($_POST['submit']))
{
 $to = "admin@hosting-mate.com"; // this is your Email address
 $headers = "From:" . $from ;

 $name = $_POST['name'];
 $from = $_POST['email']; // this is the sender's Email address
 $phone = $_POST['phone'];
 $address = $_POST['address'];
 $message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];

 $subject = "DKS Online Quote Form";
 $subject2 = "DKS Electrical and Data";

 $response = "Mail Sent. Thank you " . $name . " for contacting us, we will be  in contact with you shortly.";

 mail($to,$subject,$message,$headers);
 mail($from,$subject2,$response);

 header('Location: ../index.php');
 // You can also use header('Location: thank_you.php'); to redirect to another page.
 // You cannot use header and echo together. It's one or the other.
}else {
 echo "Error: You need to Submit the Form!";
 }
?>

在HTML代码中更改此内容:

<input type="submit" class="button" id="Button2" value="SEND" style="position:absolute;left:0%;top:640px;width:100%;height:80px;font-family:font_header;font-size:27px;z-index:20">

<input type="submit" class="button" name="submit" id="Button2" value="SEND"   style="position:absolute;left:0%;top:640px;width:100%;height:80px;font-family:font_header;font-size:27px;z-index:20">