douxie7738 2013-02-28 08:25 采纳率: 0%
浏览 27
已采纳

用php发送邮件不会给出预期的结果

I have this form which I used all over my site and it's working fine but when I used extra data into my content it stop sending even it don't display the message that there was an error or any other message

this is the form it self

<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>

and this is my php code

<?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 
 From: ".$name.",
 Email: ".$email.", 
 Company: ".$company.", 
 He rate our services as: ".$s_rate.", 
 He know about us from: ".$know.", 
 Would he recommend us to his friends: ".$recommend.", 
 He's suggestions was: ".$message; 
            $headers = 'From: feedback@hostnile.com' . "
" .
    'Reply-To: johnef_sh@hotmail.com' . "
" .
    '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>";
   }
}
?>

now when I submit the form I return to the same page without any results the mail not sending anything and not even message.

the content is

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

does it make any different that I put many data in it.

Thanks and regards.

  • 写回答

2条回答 默认 最新

  • doushen1026 2013-02-28 08:32
    关注

    You have

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

    but check for submission using

    isset($_POST['submit'])
    

    You use upper case Submit in the name-attribute of the button, but check for lower case submit in the PHP script.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。