<?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>
答案 0 :(得分:0)
删除,它应该工作。看看这里method="post" enctype="text/plain" are not compatible?
enctype="text/plain"