标题已经发出

时间:2015-08-06 17:42:42

标签: php

我已经在这个网站上查找了我的问题的答案,并尝试了我找到的一些建议,但没有任何东西可以解决这个错误:

  

警告:无法修改标题信息 - 第23行/home/thegrowt/public_html/sfs/test.php中已经发送的标题(在/home/thegrowt/public_html/sfs/test.php:1中开始输出)< / p>

我的PHP在第1行打开,上面没有任何内容,并且每行之后没有任何杂散空格....

<?php

if ($_POST) {
    if (empty($_POST['first']) || 
    empty($_POST['last']) || 
    empty($_POST['email']) ||
    empty($_POST['zip'])) {
        $errors = 1;
    } elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $errors = 2;
    } else {
        $to = "test@test.com";
        $subject = "Subject";
        $message .= "First Name: ".$_POST['first']."\n";
        $message .= "Last Name: ".$_POST['last']."\n";
        $message .= "Email: ".$_POST['email']."\n";
        $message .= "Zip: ".$_POST['zip']."\n";
        $message .= "Country: ".$_POST['country']."\n";
        $message .= "Phone: ".$_POST['phone']."\n";
        $from = $_POST['email'];
        $headers = "From:" . $from;
        mail($to,$subject,$message,$headers);
        header('Location: thank-you.php');
        exit;
    }
}

if ($errors == 1) {
    $errors = "Please fill out all required fields!";
} elseif ($errors == 2) {
        $errors = "Please enter a valid email";
}

?>
<!doctype html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<title>Title</title>
<link rel="stylesheet" href="css/main.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/main.js"></script>
</head>

0 个答案:

没有答案