我意识到这种问题被问了很多,但玩这个代码和在网上寻找答案没有得到任何帮助,所以我在这里,我们!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