I've created a website and I have no business working in php. The website is up and running, but the form is not working correctly. Right now it submits to my sform.php file, but just shows a blank page and does not submit to the email in the $to portion (which I replaced with redacted@redacted.com for privacy reasons). Here is the form code along with the php. I'm sure you all will know exactly what the issue is right away. Sorry for my ignorance.
Form:
<form class="form-horizontal" role="form" method="post" action="sform.php">
<div class="form-group">
<label for="name" class="col-lg-4 control-label"></label>
<div class="col-lg-10">
<input type="name" class="form-control" id="name" placeholder="Your Name">
</div>
</div>
<div class="form-group">
<label for="email" class="col-lg-4 control-label"></label>
<div class="col-lg-10">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="phone" class="col-lg-4 control-label"></label>
<div class="col-lg-10">
<input type="phone" class="form-control" id="phone" placeholder="Phone">
</div>
</div>
<div class="form-group">
<label for="company" class="col-lg-4 control-label"></label>
<div class="col-lg-10">
<input type="company" class="form-control" id="company" placeholder="Company Name">
</div>
</div>
<div class="form-group">
<label for="message" class="col-lg-4 control-label"></label>
<div class="col-lg-10">
<textarea rows="3" class="form-control" id="message" placeholder="What can we do for you?"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-lg-10">
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-ok-sign"></span> Submit</button>
</div>
</div>
</form><!-- form -->
=========================================================
PHP:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['comments'];
$human = intval($_POST['human']);
$from = 'redacted';
$to = 'redacted@redacted.com';
$subject = 'redacted ';
$body = "From: $name\n E-Mail: $email\n Comments: $comments\n";
// 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['comments']) {
$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! We will be in contact with you shortly.</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again.</div>';
}
}
}
?>
==================================================================
Thanks again for the help!