このフォームのどこが間違っているのか、誰でも指摘できますか? 送信者からの「メール」に返信する代わりに、サーバーのメールを受け取ります。
phpコードは次のとおりです。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: business.com';
$to = 'anyone@gmail.com';
$subject = 'A new Message from your website business.com';
$human = $_POST['human'];
$headers = 'From: info@business.com' . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if ($human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p>';
}
}
?>
ここにhtmlがあります
<form method="post" action="contact.php" target="contactIframe" name="contact">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea></br>
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here"></br></br>
<input id="submit" name="submit" type="submit" value="Submit">
<input type="button" name="reset_form" value="Clear" onclick="this.form.reset();">
</form>
みんな、ありがとう