Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
PHP联系人表单错误_Php - Fatal编程技术网

PHP联系人表单错误

PHP联系人表单错误,php,Php,有我的联系形式im建设只是它没有发送以下 我试着将结果打印到浏览器上,但由于某种原因它不会发送,有人能看到语法错误吗 <?php $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $addr = $_POST['addr']; $postcode = $_POST['postcode']; $landline = $_POST['landline']; $mob = $_POST[

有我的联系形式im建设只是它没有发送以下

我试着将结果打印到浏览器上,但由于某种原因它不会发送,有人能看到语法错误吗

<?php 

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$addr = $_POST['addr'];
$postcode = $_POST['postcode'];
$landline = $_POST['landline'];
$mob = $_POST['mob'];
$carw = $_POST['carw'];
$depo = $_POST['depo'];
$marsta = $_POST['marsta'];
$ressta = $_POST['ressta'];
$to = "liam@.co.uk";

    //begin of HTML message
    $message = "
  From : $name $lname,
  Email: $email,
  Address: $addr $postcode,
  Landline: $landline,
  Mobile: $mob,
  Car Wanted: $carw,
  Deposit Available: $depo,
  Marital Status: $marsta,
  Residential Status: $ressta";
   //end of message

    // To send the HTML mail we need to set the Content-type header.
    $headers = "MIME-Version: 1.0rn";
    $headers .= "Content-type: text/html; charset=iso-8859-1rn";
    $headers  .= "From: Website Enquiry";




if (isset($name))
{
       // now lets send the email.
   mail($to, $subject, $message, $headers);

header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=Thankyou, we will be in touch shortly.');

} else {header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=There was an error sending your message, Please try again.');}

?> 

不要使用
rn
,请使用
\r\n

URL编码您的
位置:
标题数据。URL没有空格

也可以考虑,不是每个人都能阅读HTML电子邮件。除了HTML版本外,还发送文本版本


最后,您可能不想发送这样一封开放式电子邮件,因为垃圾邮件发送者很容易使用此脚本使用它。

它不起作用的原因是您正在检查是否设置了
$name
,但显然没有设置。您有一个
$fname

@Liam,请参阅MetalFrog的答案。+1以获得代码改进建议。进行一点输入验证也不会有什么坏处。不要自己构建mime消息。使用swiftmailer或phpmailer。