php - 电子邮件表单

时间:2013-04-09 22:17:55

标签: php forms email

艰难的一天,我确信我错过了一些明显的东西,但有人可以浏览一下并解释为什么我收到一封空白的电子邮件吗?我尽可能地打破了这个,但似乎无法找到其空白的原因

<?php
$to = 'blah@blah.com';
$name = $_POST['name'] ;
$subject = "Message from: $name";
$message = $_POST['comment'] ;
$robotest = $_REQUEST['robotest'];
$body = "From: $name \r\nMessage: $message";

/*
if (preg_match($match, $from) ||
preg_match($match, $subject) ||
preg_match($match, $body)) {
die("Header injection detected.");
}
*/

if ($sent == '0') {
mail($to, $subject, $body) or die("Error Bro!!!");
$sent = 1;
}

if ($robotest) {
$error = print("You are a gutless robot.");
}

 if ($name == ' '){
print("You have not entered a name, please go back and try again");
 } else {
$send = mail($to, $subject, $body);
print("Thank you for contacting us. We will be in touch with you very soon.");
 }
 ?>

HTML:

            <form style="margin-left: 10%;" method="post" action="coming-soon/email.php" enctype="text/plain">
                <br>
                <input id="fName" name="name" type="text"  placeholder="Name (required)"><br><br>
                <p class="robotic" id="pot">
                    <label>If you're human leave this blank:</label>
                    <input name="robotest" type="text" id="robotest" class="robotest" />
                </p>
                <textarea id="fComment" name="comment" style="height: inherit; margin: 0 40% 1% 0;" rows="10" cols="50" placeholder="Place your Message here...."></textarea>
                <input type="submit" value="Send">
                <input type="reset" value="Reset">
            </form>

1 个答案:

答案 0 :(得分:0)

删除,它应该工作。看看这里method="post" enctype="text/plain" are not compatible?

 enctype="text/plain"