I have looked this up and found a few solutions, but none of those really worked in my situation and there are a TON like around, but most of them so far haven't been what I am working toward, they're usually a lot more complex to the point where my lack of php makes it impossible to follow.
I am setting up an contact page and all seems fine, but it doesn't actually send out the email for some reason.
<div class="contact-form">
<form action="contact.php" class="form-horizontal" method=
"post">
<div class="form-group">
<label class="col-sm-2 control-label" for=
"name">Name</label>
<div class="col-sm-10">
<input class="form-control" id="name"
name="name" placeholder=
"First & Last Name" type="text" value=
"<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for=
"email">Email</label>
<div class="col-sm-10">
<input class="form-control" id="email"
name="email" placeholder=
"example@domain.com" type="email"
value="<?php echo htmlspecialchars($_POST['email']); ?>">
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for=
"message">Message</label>
<div class="col-sm-10">
<textarea class="form-control" name=
"message" rows="4">
<?php echo htmlspecialchars($_POST['message']);?>
</textarea> <?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for=
"human">2 + 3 = ?</label>
<div class="col-sm-10">
<input class="form-control" id="human"
name="human" placeholder="Your Answer"
type="text">
<?php echo "<p class='text-danger'>$errHuman</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input class="btn btn-primary" id=
"submit" name="submit" type="submit"
value="Send">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</form>
</div>
and this is in the came contact.php page at the top
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_POST["submit"]) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$from = 'Demo Contact Form';
$to = 'Isetmyemailherealready@editedforprivacy.com';
$subject = 'Message from Contact Demo ';
$body ="From: $name\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Please enter your message';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Your anti-spam is incorrect';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later.</div>';
}
}
}
?>
I haven't really had any experience with PHP so I am clueless as of where to start, I looked up a php guide for this, and got this far, but now I am stuck because it says it sent the email (gives me the "Thank You? I will be in touch" message), but I never get anything to my email.