2014-09-01 41 views
0

我對PHP很新,我有這個在Windows服務器上工作,但最近剛剛遷移到LINUX服務器,現在窗體顯示爲發送,但沒有任何通過?任何幫助將不勝感激,,謝謝簡單的聯繫PHP不發送

HTML

<div class="wrapper"> 
<div id="contact_form"> 
<form action="html_form_send.php" method="POST"> 

    <label> 
    <span>Name*:</span> 
    <br> 
    <input type="text" placeholder="Please enter your name" name="name" id="name" required autofocus> 
    </label> 



    <label> 
    <span>Phone:</span> 
<input type="text" placeholder="Please enter your phone" name="phone" id="phone"> 
    </label> 

    <label> 
    <span>Email*:</span> 
    <input type="email" placeholder="[email protected]" name="email" id="email" required> 
    </label> 
     <label> 
    <span>Message*:</span> 
    <input name="message" type="text" required id="message" placeholder="Message" value=""> 
     </label> 

    <input class="sendButton" type="submit" name="Submit" value="Send"> 

</form> 
</div> 

PHP

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone= $_POST['phone']; 
$message = $_POST['message']; 

$formcontent="From: $name \n Phone: 
$phone \n 
Email: 
$email \n 
Message: 
$message \n"; 
$recipient = "[email protected]"; 
$subject = "Design Contact"; 
$mailheader = "From: $email \n"; 
mail($recipient, $subject,$formcontent, $mailheader) or die("Error!");header("Location: http://website.com/website.com/success.html"); 

?>

建議?

+0

它發出一個成功的消息,,但沒有顯示出來? – 2014-09-01 21:37:51

+0

您是否檢查垃圾郵件文件夾? – HddnTHA 2014-09-01 21:39:25

+0

1.檢查錯誤日誌。 2.請,請不要使用此代碼。永遠。使用表單中的原始數據而不進行消毒是非常危險的 – user3791372 2014-09-01 21:39:51

回答

0

你應該使用三元的運營商,並基於該值驗證:

$name = isset($_POST['name']) ? $_POST['name'] : ""; // don't forget to sanitize 

if ($name != "") { 
    // do logic 
} 

此外,這是毫無意義的有模()語句作爲模()語句將結束所有進一步的後一個頭()執行。

如果電子郵件仍未發送,您的郵件配置可能無法正確設置。

編輯:也考慮衛生處理。 Here是一個讓你開始使用它的鏈接。

+0

謝謝大家,最終只編譯了一個正在工作的新的數據..但感謝所有偉大的信息 – 2014-09-02 23:07:24

+0

@CoryRyan php不是一種編譯語言... – Chad 2014-09-03 02:32:56

0

你可以做這樣的事情。

if ($_POST['name'] && $_POST['email'] && $_POST['phone'] && $_POST['message']) { // your email sending logic is here: } else { echo "All fields are required.. }