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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀