I have two forms on this page. The first one works. The second one doesn't.
The answer suggested doesn't have any answers that address my issue. They recommend checking for error messages (I've already reported the error message that I received at the bottom of the question). Additionally, none of the answers for that question were even accepted as solving the issue. It seems to be an issue with my code, because one of the forms is working fine on the SAME page. So, there's must be something wrong with that form.
Contact Page PHP:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" href="_images/icon_180.png">
<link rel="apple-touch-icon" sizes="76x76" href="_images/icon_76.png">
<link rel="apple-touch-icon" sizes="120x120" href="_images/icon_120.png">
<link rel="apple-touch-icon" sizes="152x152" href="_images/icon_152.png">
<link rel="apple-touch-icon" sizes="167x167" href="_images/icon_167.png">
<link rel="apple-touch-icon" sizes="180x180" href="_images/icon_180.png">
<title>Southeast Jeet Kune Do | Augusta, GA | Contact</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css">
<link rel="stylesheet" href="_css/styles.css?v=1.0.3">
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-63178620-3', 'auto');
ga('send', 'pageview');
</script>
<script async src='//www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics --></head>
<script>
function validateForm() {
var x = document.forms["myForm"]["name"].value;
var y = document.forms["myForm"]["address"].value;
var z = document.forms["myForm"]["message"].value;
if (x == null || x == "" || y == null || y == "" || z == null || z == "") {
alert("Please fill out all required fields before you submit your message.");
return false;
}
}
function validateForm2() {
var x = document.forms["myForm2"]["name"].value;
var y = document.forms["myForm2"]["address"].value;
var z = document.forms["myForm2"]["message"].value;
if (x == null || x == "" || y == null || y == "" || z == null || z == "") {
alert("Please fill out all required fields before you submit your message.");
return false;
}
}
</script><body>
<header>
<div class="container">
<a href="index.php"><img src="_images/logo_small_text.png" alt="Southeast Jeet Kune Do Logo"></a>
<i class="zmdi zmdi-menu"></i>
</div>
</header>
<figure class="overlay"></figure>
<nav>
<img src="_images/logo_nav.png" alt="">
<ul>
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="about.php">About</a>
</li>
<li>
<a href="styles.php">Styles</a>
</li>
<li class="category">
Classes
<ul>
<li><a href="classes_adults.php">Adults</a></li>
<li><a href="classes_kids.php">Kids</a></li>
<li><a href="classes_seminars.php">Seminars</a></li>
</ul>
</li>
<li>
<a href="schedule.php">Schedule</a>
</li>
<li>
<a href="pricing.php">Pricing</a>
</li>
<li>
<a href="faq.php">FAQ</a>
</li>
<li>
<a href="contact.php">Contact</a>
</li>
</ul>
</nav>
<main class="contact">
<h1>Contact</h1>
<section>
<div class="container">
<form name="myForm" id="myForm" method="post" action="mail.php" onsubmit="return validateForm()" class="contact-form">
<h2>Have Questions?</h2>
<p>Send us an email. We will contact you shortly!</p>
<input type="text" placeholder="Name (required)" name="name">
<input type="hidden" name="email">
<input type="email" placeholder="Email Address (required)" name="address">
<input type="tel" placeholder="Phone Number" name="phone">
<textarea name="message" id="" cols="30" rows="3" placeholder="Comments (required)"></textarea>
<input type="submit">
</form>
<span class="desktop">
<h2>Phone Number</h2>
<p>706.364.8127</p>
<h2>Address</h2>
<p>4158 Washington Rd<br>Evans, GA 30809</p>
</span>
<span class="mobile">
<a href="tel:706.364.8127"><button>Call Us</button></a>
<a href="http://maps.apple.com/?daddr=4158+Washington+Rd+Evans,+GA+30809&dirflg=d&t=m"><button>Get Directions</button></a>
</span>
</div>
</section>
</main>
<script>
$('.zmdi-menu, figure.overlay').click(function(){
$('nav').toggleClass('show');
$('figure.overlay').fadeToggle(500);
})
$('.category').click(function(){
$(this).toggleClass('active');
$('ul', this).slideToggle();
});
$('#reveal_button').click(function(){
$(this).fadeOut(500);
$('.form_hidden').delay(500).slideDown(500);
});
</script>
<footer>
<div class="container cf">
<div class="four">
<ul>
<li>Menu</li>
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="styles.php">Styles</a></li>
<li><a href="classes_adults.php">Classes</a></li>
<li><a href="schedule.php">Schedule</a></li>
<li><a href="pricing.php">Pricing</a></li>
<li><a href="faq.php">FAQ</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
<div class="four">
<ul>
<li>Social</li>
<li><a href="https://www.facebook.com/SoutheastJKD/" target="_blank">Facebook</a></li>
<li><a href="https://twitter.com/southeastjkd" target="_blank">Twitter</a></li>
<li><a href="https://www.instagram.com/southeastjeetkunedo/" target="_blank">Instagram</a></li>
</ul>
</div>
<div class="four">
<ul>
<li>Contact Info</li>
<li>706.364.8127</li>
<li>4158 Washington Rd<br>
Evans, GA 30809</li>
</ul>
</div>
<div class="four">
<h2>Have Questions?</h2>
<p>Send us an email. We will contact you shortly!</p>
<form name="myForm2" id="myForm2" method="post" action="mail.php" onsubmit="return validateForm2()" class="contact-form footer">
<input type="text" placeholder="Name (required)" name="name">
<input type="hidden" name="email">
<input type="email" placeholder="Email Address (required)" name="address">
<input type="tel" placeholder="Phone Number" name="phone">
<textarea name="message" id="" cols="30" rows="3" placeholder="Comments (required)"></textarea>
<input type="submit">
</form>
</div>
</div>
</footer></body>
</html>
mail.php:
<?php
if ( $_POST['email'] != '' ) {
die("You are a bot!");
} else {
$name = $_POST['name'];
$email = $_POST['address'];
$phone = $_POST['phone'];
$comments = $_POST['message'];
require_once 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddAddress('bboysupaman@gmail.com');
$mail->AddCC("jesse@happyninja.io");
$mail->SetFrom($email, $name);
$mail->Subject = 'Southeast JKD Contact Form';
$mail->MsgHTML("Name: $name<br><br>Email: $email<br><br>Phone: $phone<br><br>Comments: $comments");
$mail->Send();
header("Location: http://southeastjkd.com/success.php");
} catch (phpmailerException $e) {
header("Location: http://southeastjkd.com/failure.php");
} catch (Exception $e) {
header("Location: http://southeastjkd.com/failure.php");
}
}
?>
I've spent many, many hours Googling and going through my code. Maybe I'm overlooking something simple... But, I can't figure out why the second form (myForm2) won't work! Any thoughts?
The error that is caught is simply: "Could not instantiate mail function."