2013-02-28 83 views
0

我有這種形式,我用我所有的網站,它工作正常,但當我用額外的數據到我的內容它停止發送,即使它不顯示消息,那裏是一個錯誤或任何其他消息發送一封郵件與php不給予預期的結果

這是形式,它自

<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 = '[email protected]'; 
      $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: [email protected]' . "\r\n" . 
    'Reply-To: [email protected]' . "\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; 

這有什麼不同,我把很多數據在裏面。

感謝和問候。

+0

你有沒有嘗試'回聲'的一切,以確保你正確地調用函數? – L0j1k 2013-02-28 08:27:15

+0

你有錯誤報告嗎? – 2013-02-28 08:28:41

回答

0

你有

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

但檢查使用

isset($_POST['submit']) 

提交您的按鈕name -attribute使用大寫Submit,但您在PHP腳本小寫submit

+0

謝謝@Oswald你是對的它只是「S」再次感謝兄弟的幫助 – 2013-02-28 08:52:23

0

如果你在本地主機上,它會給你從本地主機端口25發送郵件的錯誤..爲了發送郵件從本地主機,你需要phpmailerswiftmailer或其他smpt選項。

您可以在本地使用設置SMTP郵件服務器並測試郵件功能。

+2

即使phpmailer會返回錯誤unles你設置SMTP – 2013-02-28 08:29:03

+0

@MichaelTichoň我提到smpt在我的答案.. – 2013-02-28 08:30:15

+0

沒有注意到然後我很抱歉:) – 2013-02-28 08:32:03