我意識到這種問題被問了很多,但玩這個代碼和在網上尋找答案沒有得到任何幫助,所以我在這裏,我們!Ye olde PHP的電子郵件形式返回空白和沒有回聲
這是你的經典PHP電子郵件形式,但是當你提交它什麼也不做,頁面重新加載,沒有回聲,沒有電子郵件發送。我已經使用其他電子郵件代碼和電子郵件發送了,所以它不是一個託管的東西,但我想添加垃圾郵件驗證,現在什麼都沒有。
我很想知道我做錯了什麼。
下面的代碼:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$frage = $_POST['frage'];
$from = "From: Jimzip.com Questions & Comments";
$to = "---removed---";
$subject = "You have a question or comment from jimzip.com duuude";
$body = "From: $name\n E-mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($_POST['submit'] && $frage == '10') {
if (mail ($to, $subject, $body, $from)) {
echo "<p class='echo-message'>Your message was sent successfully. Danke!</p>";
} else {
echo "<p class='echo-message'>Sorry, something went wrong there. Could you please try again?</p>";
}
} else if ($_POST['submit'] && $frage != '10') {
echo "<p class='echo-message'>Oops, looks like the anti-spam answer was wrong. Please try again.</p>";
}
} else {
echo "<p class='echo-message'>Looks like some required fields are empty. Could you give that another try?</p>";
}
}
?>
<form action="index.php" method="POST" id="contact-form">
<label>Your name:</label>
<input name="name"><br />
<label>Your email address:</label>
<input name="email" type="email" placeholder="" ><br />
<label>What are you interested in?</label>
<textarea name="message" id="message-box"></textarea><br />
<section id="anti-spam-container">
<label>What is 5 + 5? (Anti-spam!)</label>
<input name="frage" placeholder="Answer" />
</section>
<input id="submit-button" type="submit" name="Submit" value="Go, little bytes! »" />
</form>
頁和聯繫表格可以住在http://www.jimzip.com/sandbox/05/index.php 發現這是一個在底部。
非常感謝。
這是非常危險的代碼,現場運行:) – 2013-05-06 11:35:49
提交!=提交 – 2013-05-06 11:35:56
它可能是任何東西。從檢查你的錯誤日誌開始:是否有任何錯誤(嚴格設置可能不會向'用戶'顯示任何內容,但由於出現警告/通知/錯誤而仍然存在問題,請進行一些調試:var_dump your post,check if you get到你的頁面等等 – Nanne 2013-05-06 11:36:12