duanjiuhong5843 2013-05-06 11:32
浏览 19
已采纳

你的PHP电子邮件表格返回空白而没有回声[关闭]

I realise this kind of question gets asked a lot, but playing around with this code and searching for answers online has yielded nothing helpful as yet, so I here we are!

It's your classic php email form but when you submit it does nothing, the page reloads, no echoes, no email sent. I have used other email code and the email was sent, so it's not a hosting thing, but I wanted to add spam verification, and now nothing.

I would love to know what I'm doing wrong.

Here's the code:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$frage = $_POST['frage'];
$from = "From: Jimzip.com Questions &amp; Comments";
$to = "---removed---";
$subject = "You have a question or comment from jimzip.com duuude";

$body = "From: $name
 E-mail: $email
 Message:
 $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>

The page and contact form can be found live at http://www.jimzip.com/sandbox/05/index.php It's at the bottom.

Thanks very much in advance.

  • 写回答

1条回答 默认 最新

  • dsakktdog498483070 2013-05-06 11:38
    关注

    Your submit button name is: Submit

    You're checking $_POST['submit']

    Submit is different than submit

    Case closed!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退