0

我有这个表格,我在整个网站上都使用过它,它工作正常,但是当我在我的内容中使用额外的数据时,它会停止发送,即使它没有显示有错误的消息或任何其他消息

这是它自己的形式

<form action="" method="post">
<table width="683" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td width="96">Full Name</td>
    <td colspan="4"><label for="textfield"></label>
    <input type="text" name="fname" id="fname" /></td>
  </tr>
  <tr>
    <td>E-mail</td>
    <td colspan="4"><input type="text" name="email" id="email" /></td>
  </tr>
  <tr>
    <td>Company</td>
    <td colspan="4"><input type="text" name="company" id="company" /></td>
  </tr>
  <tr>
    <td colspan="5">How do you rate our services and products:</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td width="120"><input type="radio" name="s_rate" id="Poor" value="Poor" />
Poor </td>
    <td width="120"><input type="radio" name="s_rate" id="Good" value="Good" />
Good </td>
    <td width="120"><input type="radio" name="s_rate" id="Very_Good" value="Very Good" />
Very Good </td>
    <td width="127"><input type="radio" name="s_rate" id="Excellent" value="Excellent" />
Excellent</td>
  </tr>
  <tr>
    <td colspan="5"><p>How did you know about us?</p></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="radio" name="know" id="Google" value="Google" />
Google</td>
    <td><input type="radio" name="know" id="E_mail" value="E-mail" />
E-mail</td>
    <td><input type="radio" name="know" id="A_friend" value="A friend" />
A friend</td>
    <td><input type="radio" name="know" id="Social_Media" value="Social Media" />
Social Media</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2"><input type="radio" name="know" id="advertisement" value="An advertisement at a  web site" />
An advertisement at a  web site</td>
    <td colspan="2"><input type="radio" name="know" id="Old_customer" value="I am an old customer" />
    I am an old customer</td>
  </tr>
  <tr>
    <td colspan="5">Would you recommend us to your friends and colleagues:</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="radio" name="recommend" id="Yes" value="Yes" />
Yes </td>
    <td><input type="radio" name="recommend" id="No" value="No" />
No</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5">Do you have any suggestions to make us improve our services?</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="4">
    <textarea name="message" id="message" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" id="button" value="Submit" /></td>
  </tr>
</table>
</form>

这是我的 php 代码

<?php
      if(isset($_POST['submit'])){
          echo "done";

            $name = $_POST['fname'];
            $email = $_POST['email'];
            $company = $_POST['company'];
            $s_rate = $_POST['s_rate'];
            $know = $_POST['know'];
            $recommend = $_POST['recommend'];
            $message = $_POST['message'];

            $recipient = 'johnef_sh@hotmail.com'; 
            $subject="feedback"; 

            $content = "New feedback \n From: ".$name.",\n Email: ".$email.", \n Company: ".$company.", \n He rate our services as: ".$s_rate.", \n He know about us from: ".$know.", \n Would he recommend us to his friends: ".$recommend.", \n He's suggestions was: ".$message; 
            $headers = 'From: feedback@hostnile.com' . "\r\n" .
    'Reply-To: johnef_sh@hotmail.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $retval=mail($recipient, $message, $content, $headers);

   if($retval==true)
   {
      echo "<span style='color:green; font-size:16px; margin-left:35px; font-family:Arial, Helvetica, sans-serif;'>Message sent successfully...</span>";
   }
   else
   {
      echo "<span style='color:red; font-size:16px; margin-left:35px; font-family:Arial, Helvetica, sans-serif;'>Message could not be sent...</span>";
   }
}
?>

现在,当我提交表单时,我返回同一页面,没有任何结果,邮件没有发送任何内容,甚至没有消息。

内容是

$content = "New feedback \n From: ".$name.",\n Email: ".$email.", \n Company: "
.$company.", \n He rate our services as: ".$s_rate.", \n He know about us from: "
.$know.", \n Would he recommend us to his friends: "
.$recommend.", \n He's suggestions was: ".$message;

我把很多数据放进去有什么不同吗?

谢谢并恭祝安康。

4

2 回答 2

0

如果你在本地主机上,它会给你错误,因为你没有从本地主机端口 25 发送邮件。为了从本地主机发送邮件,你需要phpmailerswiftmailer或其他smpt选项。

您可以在本地使用设置SMTP邮件服务器并测试邮件功能。

于 2013-02-28T08:28:23.933 回答
0

你有

<input type="submit" name="Submit" id="button" value="Submit" />

但检查提交使用

isset($_POST['submit'])

Submit您在按钮的- 属性中使用大写字母,但在 PHP 脚本中name检查小写字母。submit

于 2013-02-28T08:32:35.250 回答