Can anyone tell me why no matter what, when submitted, my message comes back false? Im bad at coding but this seemed easy enough, maybe I missed something obvious?
<?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>
The first bit of php is just for the email to be built and I dont think it is the problem. Im not sure if there is a problem with how the check box named "human" is being called or if the "checked" for the boxes value is giving the issue.