I run my bootstrap website on a Raspberry Pi LAMP server and I'm getting 'Error!' when sending a message using the contact form, the form uses two files using PHP Mail and the contact form is on the home page, here's the code:
Contact form on index.html:
<div class="col-sm-12">
<form class="form-horizontal" action="assets/php/contactForm.php" method="post" role="form" id="contactForm">
<div class="form-group">
<div class="col-sm-6">
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
<div class="col-sm-6">
<input type="text" name="contactEmail" class="form-control" placeholder="Email">
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<textarea name="message" class="form-control" rows="8" placeholder="Message"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-theme ladda-button" data-style="expand-left">
<span class="ladda-label">Submit</span>
</button>
</div>
</div>
</form>
contactForm.php
<?php
include("include/settings.php");
if(isset($_POST['name']) && isset($_POST['contactEmail']) && isset($_POST['message'])){
$name = $_POST['name'];
$from = $_POST['contactEmail'];
$message = $_POST['message'];
$subject = "Message from " . $name;
if (mail ($to, $subject, $message, $from)) {
$response = array('sent' => 1);
echo json_encode($response);
} else {
$response = array('sent' => 0);
echo json_encode($response);
}
}
?>
settings.php
<?php
// Contact
$to = 'xxxxxxx@hotmail.co.uk';
$subject = 'Contact Form from website';
?>
(email address removed and replaced by xxxxxxx just for this post for privacy reasons)
Any idea why i'm getting 'Error!' when using the form?