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

你的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.

Your submit button name is: Submit

You're checking $_POST['submit']

Submit is different than submit

Case closed!