0

根据我了解到的情况,我的contact.html 文件和_contact.php 文件中的所有内容都正确无误,但由于某种原因,我不断收到Chrome 错误消息“...可能已关闭或配置不正确”。

这是代码,感谢您的帮助。

contact.html 中的联系表格:

     <div class="ctext5">
    <br />
          <form id="form1" name="form1" method="post" action="_contact.php">
  <table width="557" border="0" cellspacing="10">
      <tr>
        <th width="234" scope="row"><label for="firstname">First Name:</label></th>
        <td width="545"><input type="text" name="firstname" id="firstname" /></td>
      </tr>
      <tr>
        <th scope="row"><label for="lastname">Last Name:</label></th>
        <td><input type="text" name="lastname" id="lastname" /></td>
      </tr>
      <tr>
      </tr>
      <tr>
        <th scope="row"><label for="_email">E-Mail:</label></th>
        <td><input type="text" name="_email" id="_email" /></td>
      </tr>
      <tr>
        <th scope="row"><label for="address">Address:</label></th>
        <td><input type="text" name="address" id="address" /></td>
      </tr>
      <tr>
        <th scope="row"><label for="cityzip">City/Zip:</label></th>
        <td><input type="text" name="cityzip" id="cityzip" /></td>
      </tr>
      <tr>
        <th scope="row"><label for="phone">Phone #:</label></th>
        <td><input type="text" name="phone" id="phone" /></td>
      </tr>
      <tr>
        <th height="85" scope="row"><label for="comments">Questions / Other Information</label></th>
        <td><textarea name="comments" id="comments" cols="35" rows="5"></textarea></td>
      </tr>
    </table>
  <input name="Submit" type="submit" value="Submit" />
</form>
</div>

_contact.php 的代码:

<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$_email = $_POST['_email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$cityzip = $_POST['cityzip'];
$comments = $_POST['comments'];

$headers = "MIME-Version: 1.0\r\n";
$headers = "From: $_email";
$to = 'email@domain.com';
$subject = 'Accurate Solutions Contact Form Submitted';
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n

mail($to, $subject, $message, $headers);

?>
4

3 回答 3

7

你没有关闭你的$message字符串。试试这个:

$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n";   //here the last double quote and the semicolon!

mail($to, $subject, $message, $headers);
于 2013-03-22T14:53:46.613 回答
1

解析错误

$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n

mail($to, $subject, $message, $headers);

?>

应该

$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n";

mail($to, $subject, $message, $headers);

?>
于 2013-03-22T14:55:50.097 回答
0
$message = "
First Name: $firstname \n
Last Name: $lastname \n
Phone: $phone \n
Address: $address \n
City/Zip: $cityzip \n
Email: $_email \n
Comments: $comments \n";

mail($to, $subject, $message, $headers);

?>

您在消息末尾缺少 ";

于 2013-03-22T14:56:26.327 回答