0
我正在使用以下來讓聯繫頁面向我發送包含訪問者數據的電子郵件。聯繫表格不發送數據
<form method="post" action="submit.php">
<label for="Name">Name</label>
<input type="text" name="Name" id="Name" />
<label for="Email">eMail</label>
<input type="text" name="Email" id="Email" />
<input type="submit" name="submit" value="Send" class="submit-button" />
</form>
和PHP:
<?php
$EmailFrom = "Me";
$EmailTo = "[email protected]";
$Subject = "Test";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "eMail: ";
$Body .= $Email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
當試圖出來我只得到由PHP文件,但由遊客插入的信息沒有準備的電子郵件正文中,這樣的:
名稱: 電子郵件:
你確定你有安裝在機器上的郵件服務器? –
我已經上傳到客戶端服務器但沒有結果。 – no0ne
嘗試修剪而不是修剪(最佳實踐)。 http://stackoverflow.com/questions/5643496/are-php-functions-case-sensitive – Waygood