我在运行php contatc页面时遇到错误


I am getting an erro while running a php contatc page

警告:无法修改标题信息-标题已由(输出开始于C:''examplep''htdocs''contact-form-submission.php)在第5行的C:''examplep''tdocs''contact-form-submission.php中发送

<html>
<form method="POST" action="contact-form-submission.php" class="well smallspace">
          Name<br><input type="text" name="name" placeholder="Type you name here" style="width:85%" required><br>
          Phone Number<br><input type="Number" name="phnumber" placeholder="Type your phone number" style="width:85%" required/><br>
          Email id<br><input type="email" name="emailid" placeholder="Type you email id" style="width:85%" required/><br>
          Enter your message<br>
          <textarea rows="5" cols="30" name="message" placeholder="Type you message here" style="width:85%" ></textarea><br>
          <input type="submit" value="Send" class="btn btn-primary"></input><br><br>
  </form>
</html
    <?php  
 // check for form submission - if it doesn't exist then send back to contact form  
    if (!isset($_POST["save"]) || $_POST["save"] != "contact") {  
        header("Location: localhost/contact.php"); exit;  
    }  
    // get the posted data  
    $name = $_POST["name"];  
    $email_address = $_POST["emailid"];  
    $message = $_POST["message"];  
    $phone = $_POST["phnumber"];
  // check that a name was entered  
    if (empty ($name))  
        $error = "You must enter your name.";  
    // check that an email address was entered  
    elseif (empty ($email_address))   
        $error = "You must enter your email address.";  
    // check for a valid email address  
    elseif (!preg_match("/^[_a-z0-9-]+('.[_a-z0-9-]+)*@[a-z0-9-]+('.[a-z0-9-]+)*('.[a-z]{2,3})$/", $email_address))  
        $error = "You must enter a valid email address.";  
    // check that a message was entered  
    elseif (empty ($message))  
        $error = "You must enter a message.";  
    // check whether a valid phone number
    elseif(ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", $phone) ) 
         $error = 'Please enter your valid phone number';

    // check if an error was found - if there was, send the user back to the form  
    if (isset($error)) {  
        header("Location: contact.php?e=".urlencode($error)); exit;  
    }  
    // write the email content  
    $email_content = "Name: $name'n";  
    $email_content .= "Email Address: $email_address'n";  
    $email_content .= "Phone number: $phone";  
    $email_content .= "Message:'n'n$message";  
    // send the email  
    mail ("abc@xyz.com","New Contact Message",$email_content);  
    // send the user back to the form  
    header("Location: contact.php?s=".urlencode("Thank you for your message.")); exit;  
    ?>  

ab

听起来您的文件顶部可能有额外的空间(在<?php标记(既不是空格也不是换行符)。

编辑:根据您更新的代码,尝试将PHP代码放在HTML之上,因为您不能在浏览器的任何输出之后有PHP头()(HTML计数)。