任何人都可以告诉我为什么无论什么时候提交,我的消息都会丢失?我很难编码,但这似乎很容易,也许我错过了一些明显的东西?
<?php
$name = $_POST['name']; //Grabs what is typed in the name box
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Rissotos'; //Will say where the email is coming from
$to = 'myemail@gmail.com'; //where the email is being sent
$subject = 'Rissotos Message';//Built in subject Line
$body = "From: $name\n E-Mail: $email\n Message:\n $message";//Store all Variables
?>
<?php
if ($_POST['submit'] && $human =='checked') {//checks spam
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';//Message if all is filled out
} else {
echo '<p>Something went wrong, go back and try again!</p>';//Message if something was not filled out properly
}
}else if ($_POST['submit'] && $human !='checked') {
echo '<p>No Robots Allowed!</p>';
}
?>
<form method="post" action="contactUs.php">
<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>
<p> By checking this box, you validate that you are not a Robot.</p>
<input name="human" type="checkbox" value="checked" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
php的第一部分仅用于构建电子邮件,我不认为这是问题所在。我不确定复选框如何命名&#34; human&#34;正在被调用或者如果&#34;被检查&#34;对于盒子来说价值就是问题。