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!

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

报告相同问题?

悬赏问题

  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False